Package com.foundationdb.ais.model.aisb2

Examples of com.foundationdb.ais.model.aisb2.AISBBasedBuilder$ActualBuilder


    public static void install(String url, String jar, long deploy) {
        ServerQueryContext context = ServerCallContextStack.getCallingContext();
        ServerSession server = context.getServer();
        TableName jarName = jarName(server, jar);
        DDLFunctions ddl = server.getDXL().ddlFunctions();
        NewAISBuilder aisb = AISBBasedBuilder.create(server.getDefaultSchemaName(),
                                                     ddl.getTypesTranslator());
        aisb.sqljJar(jarName).url(url, true);
        SQLJJar sqljJar = aisb.ais().getSQLJJar(jarName);
        ddl.createSQLJJar(server.getSession(), sqljJar);
        if (deploy != 0) {
            new SQLJJarDeployer(context, jarName).deploy();
        }
    }
View Full Code Here


    public static void replace(String url, String jar) {
        ServerQueryContext context = ServerCallContextStack.getCallingContext();
        ServerSession server = context.getServer();
        TableName jarName = jarName(server, jar);
        DDLFunctions ddl = server.getDXL().ddlFunctions();
        NewAISBuilder aisb = AISBBasedBuilder.create(server.getDefaultSchemaName(),
                                                     ddl.getTypesTranslator());
        aisb.sqljJar(jarName).url(url, true);
        SQLJJar sqljJar = aisb.ais().getSQLJJar(jarName);
        ddl.replaceSQLJJar(server.getSession(), sqljJar);
        server.getRoutineLoader().checkUnloadSQLJJar(server.getSession(), jarName);
    }
View Full Code Here

        schemaManager.unRegisterSystemRoutine(new TableName(SCHEMA, ADD_ROLE_PROC_NAME));
        schemaManager.unRegisterSystemRoutine(new TableName(SCHEMA, ADD_USER_PROC_NAME));
    }

    protected AkibanInformationSchema buildSystemObjects() {
        NewAISBuilder builder = AISBBasedBuilder.create(SCHEMA, schemaManager.getTypesTranslator());
        builder.table(ROLES_TABLE_NAME)
            .autoIncInt("id", 1)
            .colString("name", 128, false)
            .pk("id")
            .uniqueKey("role_name", "name");
        builder.table(USERS_TABLE_NAME)
            .autoIncInt("id", 1)
            .colString("name", 128, false)
            .colString("password_basic", 36, true)
            .colString("password_digest", 36, true)
            .colString("password_md5", 35, true)
            .pk("id")
            .uniqueKey("user_name", "name");
        builder.table(USER_ROLES_TABLE_NAME)
            .autoIncInt("id", 1)
            .colInt("role_id", false)
            .colInt("user_id", false)
            .pk("id")
            .uniqueKey("user_roles", "user_id", "role_id")
            .joinTo(USERS_TABLE_NAME)
            .on("user_id", "id");
        builder.procedure(ADD_ROLE_PROC_NAME)
            .language("java", Routine.CallingConvention.JAVA)
            .paramStringIn("role_name", 128)
            .externalName(Routines.class.getName(), "addRole");
        builder.procedure(ADD_USER_PROC_NAME)
            .language("java", Routine.CallingConvention.JAVA)
            .paramStringIn("user_name", 128)
            .paramStringIn("password", 128)
            .paramStringIn("roles", 128)
            .externalName(Routines.class.getName(), "addUser");
        return builder.ais(true);
    }
View Full Code Here

        }
    }

   
    static AkibanInformationSchema createTablesToRegister(TypesTranslator typesTranslator) {
        NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator);
       
        builder.table(SERVER_INSTANCE_SUMMARY)
            .colString("server_name", DESCRIPTOR_MAX, false)
            .colString("server_version", DESCRIPTOR_MAX, false)
            .colString("server_host", IDENT_MAX, false)
            .colString("server_store", IDENT_MAX, false)
            .colBigInt("server_jit_compiler_time", false);
       
        builder.table(SERVER_SERVERS)
            .colString("server_type", IDENT_MAX, false)
            .colBigInt("local_port", true)
            .colSystemTimestamp("start_time", false)
            .colBigInt("session_count", true);
       
        builder.table(SERVER_SESSIONS)
            .colBigInt("session_id", false)
            .colBigInt("caller_session_id", true)
            .colSystemTimestamp("start_time", false)
            .colString("server_type", IDENT_MAX, false)
            .colString("remote_address", DESCRIPTOR_MAX, true)
            .colString("session_status", DESCRIPTOR_MAX, true)
            .colBigInt("query_count", false)
            .colString("last_query_executed", PATH_MAX, true)
            .colSystemTimestamp("query_start_time", true)
            .colSystemTimestamp("query_end_time", true)
            .colBigInt("query_row_count", true)
            .colString("prepared_name", IDENT_MAX, true);
       
        builder.table(ERROR_CODES)
            .colString("code", 5, false)
            .colString("name", DESCRIPTOR_MAX, false)
            .colString("message", IDENT_MAX, false)
            .colString("description", PATH_MAX, true);

        builder.table(ERROR_CODE_CLASSES)
            .colString("class", 2, false)
            .colString("description", PATH_MAX, true);

        builder.table(SERVER_PARAMETERS)
            .colString("parameter_name", IDENT_MAX, false)
            .colString("current_value", PATH_MAX, false);

        builder.table(SERVER_MEMORY_POOLS)
            .colString("name", IDENT_MAX, false)
            .colString("type", DESCRIPTOR_MAX, false)
            .colBigInt("used_bytes", false)
            .colBigInt("max_bytes", false)
            .colBigInt("peak_bytes", false);

        builder.table(SERVER_GARBAGE_COLLECTORS)
            .colString("name", IDENT_MAX, false)
            .colBigInt("total_count", false)
            .colBigInt("total_milliseconds", false);

        builder.table(SERVER_TAPS)
            .colString("tap_name", IDENT_MAX, false)
            .colBigInt("in_count", false)
            .colBigInt("out_count", false)
            .colBigInt("total_nanoseconds", false);

        builder.table(SERVER_PREPARED_STATEMENTS)
            .colBigInt("session_id", false)
            .colString("prepared_name", IDENT_MAX, true)
            .colString("statement", PATH_MAX, true)
            .colSystemTimestamp("prepare_time", true)
            .colBigInt("estimated_row_count", true);

        builder.table(SERVER_CURSORS)
            .colBigInt("session_id", false)
            .colString("cursor_name", IDENT_MAX, true)
            .colString("statement", PATH_MAX, true)
            .colString("prepared_name", IDENT_MAX, true)
            .colSystemTimestamp("creation_time", true)
            .colBigInt("row_count", true);

        builder.table(SERVER_USERS)
            .colString("user_name", IDENT_MAX, false)
            .colBigInt("statement_count", false);
           
        return builder.ais(false);
    }
View Full Code Here

    //
    // Internal
    //

    private static AkibanInformationSchema createStatsTables(SchemaManager schemaManager) {
        NewAISBuilder builder = AISBBasedBuilder.create(INDEX_STATISTICS_TABLE_NAME.getSchemaName(),
                                                        schemaManager.getTypesTranslator());
        builder.table(INDEX_STATISTICS_TABLE_NAME.getTableName())
                .colBigInt("table_id", false)
                .colBigInt("index_id", false)
                .colSystemTimestamp("analysis_timestamp", true)
                .colBigInt("row_count", true)
                .colBigInt("sampled_count", true)
                .pk("table_id", "index_id");
        builder.table(INDEX_STATISTICS_ENTRY_TABLE_NAME.getTableName())
                .colBigInt("table_id", false)
                .colBigInt("index_id", false)
                .colInt("column_count", false)
                .colInt("item_number", false)
                .colString("key_string", 2048, true, "latin1")
                .colVarBinary("key_bytes", 4096, true)
                .colBigInt("eq_count", true)
                .colBigInt("lt_count", true)
                .colBigInt("distinct_count", true)
                .pk("table_id", "index_id", "column_count", "item_number")
                .joinTo(INDEX_STATISTICS_TABLE_NAME.getSchemaName(), INDEX_STATISTICS_TABLE_NAME.getTableName(), "fk_0")
                .on("table_id", "table_id")
                .and("index_id", "index_id");

        // Statistics service relies on decoding rowdata manually
        if (schemaManager instanceof FDBSchemaManager) {
            Group istn = builder.unvalidatedAIS().getTable(INDEX_STATISTICS_TABLE_NAME).getGroup();
            istn.setStorageDescription(new FDBStorageDescription(istn, "rowdata"));

            Collection<TableIndex> collection = builder.unvalidatedAIS().getTable(INDEX_STATISTICS_TABLE_NAME).getIndexes();
            for (TableIndex ti : collection) {
                ti.setStorageDescription(new FDBStorageDescription(ti, "rowdata"));
            }

            Group isetn = builder.unvalidatedAIS().getTable(INDEX_STATISTICS_ENTRY_TABLE_NAME).getGroup();
            isetn.setStorageDescription(new FDBStorageDescription(isetn, "rowdata"));

            Collection<TableIndex> collection_isetn = builder.unvalidatedAIS().getTable(INDEX_STATISTICS_ENTRY_TABLE_NAME).getIndexes();
            for (TableIndex ti : collection_isetn) {
                ti.setStorageDescription(new FDBStorageDescription(ti, "rowdata"));
            }
        }
       
        builder.procedure(TableName.SYS_SCHEMA, "index_stats_delete")
               .language("java", Routine.CallingConvention.JAVA)
               .paramStringIn("schema_name", 128)
               .externalName(IndexStatisticsRoutines.class.getCanonicalName(), "delete");
        builder.procedure(TableName.SYS_SCHEMA, "index_stats_dump_file")
               .language("java", Routine.CallingConvention.JAVA)
               .paramStringIn("schema_name", 128)
               .paramStringIn("file_name", 4096)
               .returnString("file_path", 4096)
               .externalName(IndexStatisticsRoutines.class.getCanonicalName(), "dumpToFile");
        builder.procedure(TableName.SYS_SCHEMA, "index_stats_dump_string")
               .language("java", Routine.CallingConvention.JAVA)
               .paramStringIn("schema_name", 128)
               .returnString("yaml", 1048576)
               .externalName(IndexStatisticsRoutines.class.getCanonicalName(), "dumpToString");
        builder.procedure(TableName.SYS_SCHEMA, "index_stats_load_file")
               .language("java", Routine.CallingConvention.JAVA)
               .paramStringIn("schema_name", 128)
               .paramStringIn("file_name", 4096)
               .externalName(IndexStatisticsRoutines.class.getCanonicalName(), "loadFromFile");

        return builder.ais(true);
    }
View Full Code Here

                return row;
            }
        }
    }
    static AkibanInformationSchema createTablesToRegister(TypesTranslator typesTranslator) {
        NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator);
       
        builder.table(STORAGE_ALERTS_SUMMARY)
            .colString("alert_level", DESCRIPTOR_MAX, false)
            .colBigInt("warn_log_interval", false)
            .colBigInt("error_log_interval", false)
            .colBigInt("history_length", false);
       
       
        builder.table(STORAGE_BUFFER_POOLS)
            .colBigInt("buffer_size", false)
            .colBigInt("buffer_count", false)
            .colBigInt("valid_pages", false)
            .colBigInt("dirty_pages", false)
            .colBigInt("reader_claimed_pages", false)
            .colBigInt("writer_claimed_pages", false)
            .colBigInt("hit_count", false)
            .colBigInt("miss_count", false)
            .colBigInt("new_count", false)
            .colBigInt("evict_count", false)
            .colBigInt("write_count", false)
            .colBigInt("forced_chkpt_count", false)
            .colBigInt("forced_write_count", false);
           
        builder.table(STORAGE_CHECKPOINT_SUMMARY)
            .colBigInt("checkpoint_interval", false);

       
        builder.table(STORAGE_CLEANUP_MANAGER_SUMMARY)
            .colBigInt ("accepted_count", false)
            .colBigInt ("refused_count", false)
            .colBigInt("performed_count", false)
            .colBigInt("error_count", false)
            .colBigInt("enqueued_count", false)
            .colBigInt("poll_interval", false)
            .colBigInt("min_prune_delay", false);

        builder.table(STORAGE_IO_METER_SUMMARY)
            .colBigInt("io_rate", false)
            .colBigInt("quiescent_threshold", false)
            .colString("log_file", PATH_MAX);
       
        builder.table(STORAGE_IO_METERS)
            .colString("operation", DESCRIPTOR_MAX, false)
            .colBigInt("total_bytes", false)
            .colBigInt("operations", false);
       
        builder.table(STORAGE_JOURNAL_MANAGER_SUMMARY)
            .colBigInt("block_size", false)
            .colBigInt("base_address", false)
            .colBigInt("current_address", false)
            .colBigInt("page_map_size", false)
            .colBigInt("recovery_status", false)
            .colBigInt("journaled_page_count", false)
            .colBigInt("copied_page_count", false)
            .colBigInt("dropped_page_count", false)
            .colBigInt("read_page_count", false)
            .colString("append_only", YES_NO_MAX, false)
            .colString("fast_copy", YES_NO_MAX, false)
            .colString("copy_active", YES_NO_MAX, false)
            .colString("flush_active", YES_NO_MAX, false)
            .colSystemTimestamp("checkpoint_time", false)
           
            .colBigInt("page_list_size", false)
            .colBigInt("flush_interval", false)
            .colBigInt("copier_interval", false)
            .colBigInt("copier_urgency", false)
            .colBigInt("total_commits", false)
            .colBigInt("commit_wait_time", false)
            .colBigInt("slow_alert_threshold", false)
            .colString("rollback_pruning_enabled", YES_NO_MAX, false)

            .colString("file_path", PATH_MAX, false)
            .colSystemTimestamp("create_time", false);

       
        builder.table(STORAGE_MANAGEMENT_SUMMARY)
            .colString("initialized", YES_NO_MAX, false)
            .colString("update_suspended", YES_NO_MAX, false)
            .colString("shutdown_suspended", YES_NO_MAX, false)
            .colString("version", IDENT_MAX, false)
            .colString("copyright", IDENT_MAX, false)
            .colSystemTimestamp("start_time", false)
            .colString("default_commit_policy", DESCRIPTOR_MAX, false);
       
        builder.table(STORAGE_TRANSACTION_SUMMARY)
            .colBigInt("active_floor", false)
            .colBigInt("active_ceiling", false)
            .colBigInt("active_count", false)
            .colBigInt("current_count", false)
            .colBigInt("long_running_count", false)
            .colBigInt("aborted_count", false)
            .colBigInt("free_count",false)
            .colBigInt("dropped_count", false);

        builder.table(STORAGE_TREES)
            .colString("volume_name", IDENT_MAX, false)
            .colString("tree_name", IDENT_MAX, false)
            .colString("status", DESCRIPTOR_MAX, false)
            .colBigInt("depth", false)
            .colBigInt("fetch_counter", false)
            .colBigInt("traverse_counter", false)
            .colBigInt("store_counter", false)
            .colBigInt("remove_counter", false);
           
        builder.table(STORAGE_VOLUMES)
            .colString("volume_name", IDENT_MAX, false)
            .colString("path", PATH_MAX, false)
            .colString("temporary", YES_NO_MAX, false)
            .colBigInt("page_size", false)
            .colBigInt("current_size", false)
            .colBigInt("maximum_size", false)
            .colBigInt("extension_size", false)
            .colSystemTimestamp("create_time", false)
            .colSystemTimestamp("open_time", false)
            .colSystemTimestamp("last_read_time", false)
            .colSystemTimestamp("last_write_time", false)
            .colSystemTimestamp("last_extension_time", false)
            .colBigInt("generation", false)
            .colBigInt("get_counter", false)
            .colBigInt("read_counter", false)
            .colBigInt("write_counter", false)
            .colBigInt("fetch_counter", false)
            .colBigInt("traverse_counter", false)
            .colBigInt("store_counter", false)
            .colBigInt("remove_counter", false);
        return builder.ais(false);
    }
View Full Code Here

    static AkibanInformationSchema createTablesToRegister(TypesTranslator typesTranslator) {
        // bug1127376: Grouping constraint names are auto-generated and very long. Use a big value until that changes.
        final int GROUPING_CONSTRAINT_MAX = PATH_MAX;

        NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator);
        builder.table(SCHEMATA)
                .colString("catalog_name", IDENT_MAX, true)
                .colString("schema_name", IDENT_MAX, false)
                .colString("schema_owner", IDENT_MAX, true)
                .colString("default_character_set_catalog", IDENT_MAX, true)
                .colString("default_character_set_schema", IDENT_MAX, true)
                .colString("default_character_set_name", IDENT_MAX, true)
                .colString("sql_path", PATH_MAX, true)
                .colString("default_collation_catalog", IDENT_MAX, true)
                .colString("default_collation_schema", IDENT_MAX, true)
                .colString("default_collation_name", IDENT_MAX, true);
        //primary key (schema_name)
        builder.table(TABLES)
                .colString("table_catalog", IDENT_MAX, true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false)
                .colString("table_type", IDENT_MAX, false)
                .colString("self_referencing_column", IDENT_MAX, true)
                .colText("reference_generation", true)
                .colString("is_insertable_into", YES_NO_MAX, false)
                .colString("is_typed", YES_NO_MAX, false)
                .colString("commit_action", DESCRIPTOR_MAX, true)
                .colString("default_character_set_catalog", IDENT_MAX, true)
                .colString("default_character_set_schema", IDENT_MAX, true)
                .colString("default_character_set_name", IDENT_MAX, true)
                .colString("default_collation_catalog", IDENT_MAX, true)
                .colString("default_collation_schema", IDENT_MAX, true)
                .colString("default_collation_name", IDENT_MAX, true)
                .colBigInt("table_id", true)
                .colBigInt("group_ordinal", true)
                .colString("storage_name", PATH_MAX, true)
                .colString("storage_format", IDENT_MAX, true);
        //primary key (table_schema, table_name)
        //foreign_key (table_schema) references SCHEMATA (schema_name)
        //foreign key (character_set_schema, character_set_name) references CHARACTER_SETS
        //foreign key (collations_schema, collation_name) references COLLATIONS
        //foreign key (storage_name) references STORAGE_TREES
        builder.table(COLUMNS)
                .colString("table_catalog", IDENT_MAX, true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false)
                .colString("column_name", IDENT_MAX, false)
                .colBigInt("ordinal_position", false)
                .colString("column_default", PATH_MAX, true)
                .colString("is_nullable", YES_NO_MAX, false)
                .colString("data_type", DESCRIPTOR_MAX, false)
                .colBigInt("character_maximum_length", true)
                .colBigInt("character_octet_length", true)
                .colBigInt("numeric_precision", true)
                .colBigInt("numeric_precision_radix", true)
                .colBigInt("numeric_scale", true)
                .colString("character_set_catalog", IDENT_MAX, true)
                .colString("character_set_schema", IDENT_MAX, true)
                .colString("character_set_name", IDENT_MAX, true)
                .colString("collation_catalog", IDENT_MAX, true)
                .colString("collation_schema", IDENT_MAX, true)
                .colString("collation_name", IDENT_MAX, true)
                .colString("domain_catalog", IDENT_MAX, true)
                .colString("domain_schema", IDENT_MAX, true)
                .colString("domain_name", IDENT_MAX, true)
                .colString("udt_catalog",IDENT_MAX, true)
                .colString("udt_schema", IDENT_MAX, true)
                .colString("udt_name", IDENT_MAX, true)
                .colString("scope_catalog", IDENT_MAX, true)
                .colString("scope_schema", IDENT_MAX, true)
                .colString("scope_name", IDENT_MAX, true)
                .colBigInt("maximum_cardinality", true)
                .colString("is_self_referencing", YES_NO_MAX, false)
                .colString("is_identity", YES_NO_MAX, false)
                .colString("identity_generation", IDENT_MAX, true)
                .colBigInt("identity_start", true)
                .colBigInt("identity_increment", true)
                .colBigInt("identity_maximum", true)
                .colBigInt("identity_minimum", true)
                .colString("identity_cycle", YES_NO_MAX, true)
                .colString("is_generated", YES_NO_MAX, false)
                .colString("generation_expression", PATH_MAX, true)
                .colString("is_updatable", YES_NO_MAX, true)
                .colString("sequence_catalog", IDENT_MAX, true)
                .colString("sequence_schema", IDENT_MAX, true)
                .colString("sequence_name", IDENT_MAX, true);
        //primary key(table_schema, table_name, column_name)
        //foreign key(table_schema, table_name) references TABLES (table_schema, table_name)
        //foreign key (type) references TYPES (type_name)
        //foreign key (character_set_schema, character_set_name) references CHARACTER_SETS
        //foreign key (collation_schema, collation_name) references COLLATIONS
        builder.table(TABLE_CONSTRAINTS)
                .colString("constraint_catalog", IDENT_MAX, true)
                .colString("constraint_schema", IDENT_MAX, false)
                .colString("constraint_name", GROUPING_CONSTRAINT_MAX, false)
                .colString("table_catalog", IDENT_MAX, true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false)
                .colString("constraint_type", DESCRIPTOR_MAX, false)
                .colString("is_deferrable", YES_NO_MAX, false)
                .colString("initially_deferred", YES_NO_MAX, false)
                .colString("enforced", YES_NO_MAX, false);
        //primary key (constraint_schema, constraint_table, constraint_name)
        //foreign key (table_schema, table_name) references TABLES
        builder.table(REFERENTIAL_CONSTRAINTS)
            .colString("constraint_catalog", IDENT_MAX, true)
            .colString("constraint_schema", IDENT_MAX, false)
            .colString("constraint_name", IDENT_MAX, false)
            .colString("unique_constraint_catalog", IDENT_MAX, true)
            .colString("unique_constraint_schema", IDENT_MAX, false)
            .colString("unique_constraint_name", IDENT_MAX, false)
            .colString("match_option", DESCRIPTOR_MAX, false)
            .colString("update_rule", DESCRIPTOR_MAX, false)
            .colString("delete_rule", DESCRIPTOR_MAX, false);
        //foreign key (constraint_schema, constraint_name)
        //    references TABLE_CONSTRAINTS (constraint_schema, constraint_name)
        builder.table(GROUPING_CONSTRAINTS)
                .colString("root_table_catalog", IDENT_MAX, true)
                .colString("root_table_schema", IDENT_MAX, false)
                .colString("root_table_name", IDENT_MAX, false)
                .colString("constraint_catalog",IDENT_MAX, true)
                .colString("constraint_schema", IDENT_MAX, false)
                .colString("constraint_table_name", IDENT_MAX, false)
                .colString("path", IDENT_MAX, false)
                .colBigInt("depth", false)
                .colString("constraint_name", GROUPING_CONSTRAINT_MAX, true)
                .colString("unique_catalog", IDENT_MAX, true)
                .colString("unique_schema", IDENT_MAX, true)
                .colString("unique_constraint_name", GROUPING_CONSTRAINT_MAX, true);
        //foreign key (constraint_schema, constraint_name)
        //    references TABLE_CONSTRAINTS (constraint_schema, constraint_name)
        builder.table(KEY_COLUMN_USAGE)
            .colString("constraint_catalog", IDENT_MAX, true)
            .colString("constraint_schema", IDENT_MAX, false)
            .colString("constraint_name", GROUPING_CONSTRAINT_MAX, false)
            .colString("table_catalog", IDENT_MAX, true)
            .colString("table_schema", IDENT_MAX, false)
            .colString("table_name", IDENT_MAX, false)
            .colString("column_name", IDENT_MAX, false)
            .colBigInt("ordinal_position", false)
            .colBigInt("position_in_unique_constraint", true);
        //primary key  (constraint_schema, constraint_name, column_name),
        //foreign key (constraint_schema, constraint_name) references TABLE_CONSTRAINTS
        builder.table(INDEXES)
                .colString("table_catalog", IDENT_MAX, true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false)
                .colString("index_name", IDENT_MAX, false)
                .colString("constraint_catalog", IDENT_MAX, true)
                .colString("constraint_schema", IDENT_MAX, true)
                .colString("constraint_name", IDENT_MAX, true)
                .colBigInt("index_id", false)
                .colString("storage_name", PATH_MAX, true)
                .colString("storage_format", IDENT_MAX, true)
                .colString("index_type", DESCRIPTOR_MAX, false)
                .colString("is_unique", YES_NO_MAX, false)
                .colString("join_type", DESCRIPTOR_MAX, true)
                .colString("index_method", IDENT_MAX, true);
        //primary key(table_schema, table_name, index_name)
        //foreign key (constraint_schema, constraint_name)
        //    references TABLE_CONSTRAINTS (constraint_schema, constraint_name)
        //foreign key (table_schema, table_name) references TABLES (table_schema, table_name)
        builder.table(INDEX_COLUMNS)
                .colString("index_table_catalog", IDENT_MAX, true)
                .colString("index_table_schema", IDENT_MAX, false)
                .colString("index_table_name", IDENT_MAX, false)
                .colString("index_name", IDENT_MAX, false)
                .colString("column_catalog", IDENT_MAX, true)
                .colString("column_schema", IDENT_MAX, false)
                .colString("column_table", IDENT_MAX, false)
                .colString("column_name", IDENT_MAX, false)
                .colBigInt("ordinal_position", false)
                .colString("is_ascending", IDENT_MAX, false);
        //primary key(index_table_schema, index_table, index_name, column_schema, column_table, column_name)
        //foreign key(index_table_schema, index_table_name, index_name)
        //    references INDEXES (table_schema, table_name, index_name)
        //foreign key (column_schema, column_table, column_name)
        //    references COLUMNS (table_schema, table_name, column_name)
        builder.table(SEQUENCES)
                .colString("sequence_catalog", IDENT_MAX, true)
                .colString("sequence_schema", IDENT_MAX, false)
                .colString("sequence_name", IDENT_MAX, false)
                .colString("data_type", DESCRIPTOR_MAX, false)
                .colBigInt("start_value", false)
                .colBigInt("minimum_value", false)
                .colBigInt("maximum_value", false)
                .colBigInt("increment", false)
                .colString("cycle_option", YES_NO_MAX, false)
                .colString("storage_name", IDENT_MAX, false);
        //primary key (sequence_schema, sequence_name)
        //foreign key (data_type) references type (type_name)
               
        builder.table(VIEWS)
                .colString("table_catalog", IDENT_MAX,true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false)
                .colText("view_definition", false)
                .colString("check_option", DESCRIPTOR_MAX, false)
                .colString("is_updatable", YES_NO_MAX, false)
                .colString("is_insertable_into", YES_NO_MAX, false)
                .colString("is_trigger_updatable", YES_NO_MAX, false)
                .colString("is_trigger_deletable", YES_NO_MAX, false)
                .colString("is_trigger_insertable_into", YES_NO_MAX, false);
        //primary key(table_schema, table_name)
        //foreign key(table_schema, table_name) references TABLES (table_schema, table_name)

        builder.table(VIEW_TABLE_USAGE)
                .colString("view_catalog", IDENT_MAX, true)
                .colString("view_schema", IDENT_MAX, false)
                .colString("view_name", IDENT_MAX, false)
                .colString("table_catalog", IDENT_MAX, true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false);
        //foreign key(view_schema, view_name) references VIEWS (schema_name, table_name)
        //foreign key(table_schema, table_name) references TABLES (schema_name, table_name)

        builder.table(VIEW_COLUMN_USAGE)
                .colString("view_catalog", IDENT_MAX, true)
                .colString("view_schema", IDENT_MAX, false)
                .colString("view_name", IDENT_MAX, false)
                .colString("table_catalog", IDENT_MAX, true)
                .colString("table_schema", IDENT_MAX, false)
                .colString("table_name", IDENT_MAX, false)
                .colString("column_name", IDENT_MAX, false);
        //foreign key(view_schema, view_name) references VIEWS (schema_name, table_name)
        //foreign key(table_schema, table_name, column_name) references COLUMNS
        builder.table(ROUTINES)
                .colString("specific_catalog", IDENT_MAX,true)
                .colString("specific_schema", IDENT_MAX, false)
                .colString("specific_name", IDENT_MAX, false)
                .colString("routine_catalog", IDENT_MAX, true)
                .colString("routine_schema", IDENT_MAX, false)
                .colString("routine_name", IDENT_MAX, false)
                .colString("routine_type", DESCRIPTOR_MAX, false)
                .colString("module_catalog", IDENT_MAX, true)
                .colString("module_schema", IDENT_MAX, true)
                .colString("module_name", IDENT_MAX, true)
                .colString("udt_catalog", IDENT_MAX, true)
                .colString("udt_schema", IDENT_MAX, true)
                .colString("udt_name", IDENT_MAX, true)
                .colString("routine_body", DESCRIPTOR_MAX, true)
                .colText("routine_definition", true)
                .colString("external_name", PATH_MAX, true)
                .colString("language", IDENT_MAX, false)
                .colString("parameter_style", IDENT_MAX, false)
                .colString("is_deterministic", YES_NO_MAX, false)
                .colString("sql_data_access", IDENT_MAX, true)
                .colString("is_null_call", YES_NO_MAX, true)
                .colString("sql_path", PATH_MAX, true)
                .colString("schema_level_routine", YES_NO_MAX, false)
                .colBigInt("max_dynamic_result_sets", false)
                .colString("is_user_defined_cast", YES_NO_MAX, true)
                .colString("is_implicitly_invokable", YES_NO_MAX, true)
                .colString("security_type", DESCRIPTOR_MAX, true)
                .colString("as_locator", YES_NO_MAX, true)
                .colString("is_udt_dependent", YES_NO_MAX, true)
                .colSystemTimestamp("created", true)
                .colSystemTimestamp("last_updated", true)
                .colString("new_savepoint_level", YES_NO_MAX,true);
        //primary key(routine_schema, routine_name)

        builder.table(PARAMETERS)
                .colString("specific_catalog", IDENT_MAX,true)
                .colString("specific_schema", IDENT_MAX, false)
                .colString("specific_name", IDENT_MAX, false)
                .colString("parameter_name", IDENT_MAX, true)
                .colBigInt("ordinal_position", false)
                .colString("data_type", DESCRIPTOR_MAX, false)
                .colBigInt("character_maximum_length", true)
                .colBigInt("numeric_precision", true)
                .colBigInt("numeric_precision_radix", true)
                .colBigInt("numeric_scale",true)
                .colString("parameter_mode", DESCRIPTOR_MAX, false)
                .colString("is_result", YES_NO_MAX, false)
                .colString("parameter_default", PATH_MAX, true);
        //primary key(specific_schema, specific_name, parameter_name, ordinal_position)
        //foreign key(routine_schema, routine_name) references ROUTINES (routine_schema, routine_name)
        //foreign key (type) references TYPES (type_name)

        builder.table(JARS)
                .colString("jar_catalog", IDENT_MAX, true)
                .colString("jar_schema", IDENT_MAX, false)
                .colString("jar_name", IDENT_MAX, false)
                .colString("java_path", PATH_MAX, true);
        //primary key(jar_schema, jar_name)

        builder.table(ROUTINE_JAR_USAGE)
                .colString("specific_catalog", IDENT_MAX, true)
                .colString("specific_schema", IDENT_MAX, false)
                .colString("specific_name", IDENT_MAX, false)
                .colString("jar_catalog", IDENT_MAX, true)
                .colString("jar_schema", IDENT_MAX, false)
                .colString("jar_name", IDENT_MAX, false);
        //foreign key(specific_schema, specific_name) references ROUTINES (specific_schema, specific_name)
        //foreign key(jar_schema, jar_name) references JARS (jar_schema, jar_name)

        builder.table(SCRIPT_ENGINES)
                .colInt("engine_id", false)
                .colString("engine_name", IDENT_MAX, false)
                .colString("engine_version", IDENT_MAX, false)
                .colString("language_name", IDENT_MAX, false)
                .colString("language_version", IDENT_MAX, false);
        //primary key(engine_id)

        builder.table(SCRIPT_ENGINE_NAMES)
                .colString("name", IDENT_MAX, false)
                .colInt("engine_id", false);
        //foreign key (engine_id) references SCRIPT_ENGINES (engine_id)

        builder.table(TYPES)
            .colString("type_name", IDENT_MAX, false)
            .colString("type_category", IDENT_MAX, false)
            .colString("type_bundle_name", IDENT_MAX)
            .colString("attribute_1", IDENT_MAX)
            .colString("attribute_2", IDENT_MAX)
            .colString("attribute_3", IDENT_MAX)
            .colInt("fixed_length")
            .colInt("postgres_oid")
            .colInt("jdbc_type_id")
            .colString("indexable", YES_NO_MAX);

        builder.table(TYPE_BUNDLES)
            .colString("type_bundle_name", IDENT_MAX, false)
            .colString("bundle_guid", IDENT_MAX, false);
       
        builder.table(TYPE_ATTRIBUTES)
            .colString("type_name", IDENT_MAX, false)
            .colString("attribute_name", IDENT_MAX, false);
       
        return builder.ais(false);
    }
View Full Code Here

    private void registerSystemTables() {
        final int identMax = 128;
        final int tableVersion = 1;
        final String schema = TableName.INFORMATION_SCHEMA;
        NewAISBuilder builder = AISBBasedBuilder.create(schema, schemaManager.getTypesTranslator());
        // TODO: Hidden PK too expensive?
        builder.table(CHANGES_TABLE)
               .colString("schema_name", identMax, false)
               .colString("table_name", identMax, false)
               .colString("index_name", identMax, false)
               .colInt("index_id", false)
               .colVarBinary("hkey", 4096, false);
        builder.procedure(BACKGROUND_WAIT_PROC_NAME)
               .language("java", Routine.CallingConvention.JAVA)
               .externalName(Routines.class.getName(), "backgroundWait");
        AkibanInformationSchema ais = builder.ais();
        schemaManager.registerStoredInformationSchemaTable(ais.getTable(CHANGES_TABLE), tableVersion);
        schemaManager.registerSystemRoutine(ais.getRoutine(BACKGROUND_WAIT_PROC_NAME));
    }
View Full Code Here

        }
    }

    @Before
    public void createAIS() {
        NewAISBuilder builder = CAOIBuilderFiller.createAndFillBuilder("Test");
        ais = builder.ais();
        Table customers = ais.getTable("Test", CAOIBuilderFiller.CUSTOMER_TABLE);
        assertNotNull(customers);
        Map<Table, Integer> ordinalMap = new HashMap<>();
        List<Table> remainingTables = new ArrayList<>();
       
View Full Code Here

    }

    @Test
    public void addColumnIndexSingleTableNoPrimaryKey() throws StandardException {
        TableName cName = tableName(SCHEMA, "c");
        NewAISBuilder builder = AISBBasedBuilder.create(ddl().getTypesTranslator());
        builder.table(cName).colInt("c1", true).colInt("c2", true).colInt("c3", true);

        ddl().createTable(session(), builder.unvalidatedAIS().getTable(cName));

        // Note: Not using standard id due to null index contents
        int tableId = tableId(cName);
        writeRows(
                row(tableId, 1, 2, 3),
                row(tableId, 4, 5, 6),
                row(tableId, 7, 8, 9)
        );

        builder = AISBBasedBuilder.create(ddl().getTypesTranslator());
        builder.table(cName).colInt("c1", true).colInt("c2", true).colInt("c3", true).colInt("c4", true).key("c4", "c4");
        List<TableChange> changes = new ArrayList<>();
        changes.add(TableChange.createAdd("c4"));

        ddl().alterTable(session(), cName, builder.unvalidatedAIS().getTable(cName), changes, changes, queryContext());

        expectRowsSkipInternal(
                tableId,
                row(tableId, 1, 2, 3, null),
                row(tableId, 4, 5, 6, null),
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.aisb2.AISBBasedBuilder$ActualBuilder

Copyright © 2018 www.massapicom. 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.