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);
}