1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

WL#2257 REFERENTIAL_CONSTRAINTS view

added I_S.REFARENTIAL_CONSTRAINTS table


mysql-test/r/information_schema.result:
  WL#2257 REFERENTIAL_CONSTRAINTS view
   result fix
mysql-test/r/information_schema_db.result:
  WL#2257 REFERENTIAL_CONSTRAINTS view
   result fix
mysql-test/r/information_schema_inno.result:
  WL#2257 REFERENTIAL_CONSTRAINTS view
   test case
mysql-test/t/information_schema_inno.test:
  WL#2257 REFERENTIAL_CONSTRAINTS view
   test case
sql/ha_innodb.cc:
  WL#2257 REFERENTIAL_CONSTRAINTS view
This commit is contained in:
unknown
2006-05-02 16:31:39 +05:00
parent fb2c04a15f
commit 79cc1546b2
7 changed files with 208 additions and 31 deletions

View File

@ -4231,6 +4231,75 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
}
/*
Fill and store records into I_S.referential_constraints table
SYNOPSIS
get_referential_constraints_record()
thd thread handle
tables table list struct(processed table)
table I_S table
res 1 means the error during opening of the processed table
0 means processed table is opened without error
base_name db name
file_name table name
RETURN
0 ok
# error
*/
static int
get_referential_constraints_record(THD *thd, struct st_table_list *tables,
TABLE *table, bool res,
const char *base_name, const char *file_name)
{
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_referential_constraints_record");
if (res)
{
if (!tables->view)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
thd->net.last_errno, thd->net.last_error);
thd->clear_error();
DBUG_RETURN(0);
}
if (!tables->view)
{
List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table;
show_table->file->info(HA_STATUS_VARIABLE |
HA_STATUS_NO_LOCK |
HA_STATUS_TIME);
show_table->file->get_foreign_key_list(thd, &f_key_list);
FOREIGN_KEY_INFO *f_key_info;
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
while ((f_key_info= it++))
{
restore_record(table, s->default_values);
table->field[1]->store(base_name, strlen(base_name), cs);
table->field[9]->store(file_name, strlen(file_name), cs);
table->field[2]->store(f_key_info->forein_id->str,
f_key_info->forein_id->length, cs);
table->field[4]->store(f_key_info->referenced_db->str,
f_key_info->referenced_db->length, cs);
table->field[5]->store(f_key_info->referenced_table->str,
f_key_info->referenced_table->length, cs);
table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
table->field[7]->store(f_key_info->update_method->str,
f_key_info->update_method->length, cs);
table->field[8]->store(f_key_info->delete_method->str,
f_key_info->delete_method->length, cs);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
}
}
DBUG_RETURN(0);
}
/*
Find schema_tables elment by name
@ -5160,6 +5229,22 @@ ST_FIELD_INFO files_fields_info[]=
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
ST_FIELD_INFO referential_constraints_fields_info[]=
{
{"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"CONSTRAINT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"CONSTRAINT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"UNIQUE_CONSTRAINT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"UNIQUE_CONSTRAINT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"MATCH_OPTION", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"UPDATE_RULE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"DELETE_RULE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
/*
Description of ST_FIELD_INFO in table.h
@ -5195,6 +5280,9 @@ ST_SCHEMA_TABLE schema_tables[]=
fill_plugins, make_old_format, 0, -1, -1, 0},
{"PROCESSLIST", processlist_fields_info, create_schema_table,
fill_schema_processlist, make_old_format, 0, -1, -1, 0},
{"REFERENTIAL_CONSTRAINTS", referential_constraints_fields_info,
create_schema_table, get_all_tables, 0, get_referential_constraints_record,
1, 9, 0},
{"ROUTINES", proc_fields_info, create_schema_table,
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
{"SCHEMATA", schema_fields_info, create_schema_table,