List:Commits« Previous MessageNext Message »
From:Dmitry Lenev Date:December 9 2008 12:41pm
Subject:bzr commit into mysql-6.1-fk branch (dlenev:2689) WL#148
View as plain text  
#At file:///home/dlenev/src/bzr/mysql-6.1-mil8-3/

 2689 Dmitry Lenev	2008-12-09 [merge]
      WL#148 "Foreign keys".
      
      Milestone #8 "DML words: INSERT, UPDATE, DELETE, no EOS checks".
      
      Work in progress. Merge.
modified:
  sql/fk_dd.cc
  sql/fk_dd.h

=== modified file 'sql/fk_dd.cc'
--- a/sql/fk_dd.cc	2008-12-08 19:13:22 +0000
+++ b/sql/fk_dd.cc	2008-12-09 12:41:08 +0000
@@ -88,9 +88,9 @@ uint Foreign_key_parent::get_frm_descrip
 
 
 /**
-   Get number of bytes to be reserved in parent .FRM for storing match
-   option of the foreign key (we don't store this information in .FRM
-   of parent so it is 0).
+  Get number of bytes to be reserved in parent .FRM for storing match
+  option of the foreign key (we don't store this information in .FRM
+  of parent so it is 0).
 */
 
 uint Foreign_key_parent::get_match_opt_frm_length()
@@ -100,9 +100,9 @@ uint Foreign_key_parent::get_match_opt_f
 
 
 /**
-   Get number of bytes to be reserved in parent .FRM for storing
-   name of unique constraint participating in this foreign key
-   (we don't store this information .FRM of parent so it is 0).
+  Get number of bytes to be reserved in parent .FRM for storing
+  name of unique constraint participating in this foreign key
+  (we don't store this information .FRM of parent so it is 0).
 */
 
 uint Foreign_key_parent::get_unique_constraint_name_frm_length()
@@ -112,8 +112,8 @@ uint Foreign_key_parent::get_unique_cons
 
 
 /**
-   Get number of bytes to be reserved in child .FRM for storing match
-   option of the foreign key.
+  Get number of bytes to be reserved in child .FRM for storing match
+  option of the foreign key.
 */
 
 uint Foreign_key_child::get_match_opt_frm_length()
@@ -123,11 +123,12 @@ uint Foreign_key_child::get_match_opt_fr
 
 
 /**
-   Get number of bytes to be reserved in child .FRM for storing
-   name of unique constraint participating in this foreign key.
-   We store unique constraint name of the parent in the child
-   .FRM in order to properly reflect it in UNIQUE_CONSTRAINT_NAME
-   of I_S.TABLE_CONSTRAINTS view.
+  Get number of bytes to be reserved in child .FRM for storing
+  name of unique constraint participating in this foreign key.
+
+  We store unique constraint name of the parent in the child
+  .FRM in order to properly reflect it in UNIQUE_CONSTRAINT_NAME
+  of I_S.TABLE_CONSTRAINTS view.
 */
 
 uint Foreign_key_child::get_unique_constraint_name_frm_length()
@@ -137,12 +138,12 @@ uint Foreign_key_child::get_unique_const
 
 
 /**
-   Calculate total length of .FRM section describing foreign keys.
+  Calculate total length of .FRM section describing foreign keys.
 
-   @param fkey_list        List of foreign keys for which this table is child.
-   @param parent_fkey_list List of foreign keys for which this table is parent.
+  @param fkey_list        List of foreign keys for which this table is child.
+  @param parent_fkey_list List of foreign keys for which this table is parent.
 
-   @return Length of foreign key section in .FRM file in bytes.
+  @return Length of foreign key section in .FRM file in bytes.
 */
 
 uint fk_get_frm_section_length(List<Foreign_key_child> &fkey_list,
@@ -169,15 +170,15 @@ static const char FK_FRM_FLAG_WITHIN_ONE
 
 
 /**
-   Produce .FRM file respresentation for a foreign key.
+  Produce .FRM file respresentation for a foreign key.
 
-   @param [in/out] buff_p On entering method should point to position in
-                          buffer at which FK description should begin,
-                          on leaving it will point to the position right
-                          after this description.
+  @param [in/out] buff_p On entering method should point to position in
+                         buffer at which FK description should begin,
+                         on leaving it will point to the position right
+                         after this description.
 
-   @note This function will use Foreign_key_child::get_frm_description_length()
-         bytes of buffer space.
+  @note This function will use Foreign_key_child::get_frm_description_length()
+        bytes of buffer space.
 */
 
 void Foreign_key_parent::save_to_frm(char **buff_p)
@@ -264,8 +265,8 @@ void Foreign_key_parent::save_to_frm(cha
 
 
 /**
-   Get flags for foreign key description in .FRM which are specific for
-   description in parent table.
+  Get flags for foreign key description in .FRM which are specific for
+  description in parent table.
 */
 
 char Foreign_key_parent::get_additional_flags()
@@ -275,8 +276,8 @@ char Foreign_key_parent::get_additional_
 
 
 /**
-   Save match option of the foreign key in .FRM of parent table (does
-   nothing since we don't store this information in the parent .FRM).
+  Save match option of the foreign key in .FRM of parent table (does
+  nothing since we don't store this information in the parent .FRM).
 */
 
 void Foreign_key_parent::save_match_opt(char **buff_p)
@@ -285,8 +286,8 @@ void Foreign_key_parent::save_match_opt(
 
 
 /**
-   Get table database and name of which should be saved in the description
-   of foreign key in parent table.
+  Get table database and name of which should be saved in the description
+  of foreign key in parent table.
 */
 
 TABLE_LIST* Foreign_key_parent::get_table_for_frm()
@@ -296,9 +297,9 @@ TABLE_LIST* Foreign_key_parent::get_tabl
 
 
 /**
-   Save name of the unique constraint participating in the foreign key the
-   .FRM of parent table (does nothing as we don't store this information
-   in this .FRM).
+  Save name of the unique constraint participating in the foreign key the
+  .FRM of parent table (does nothing as we don't store this information
+  in this .FRM).
 */
 
 void Foreign_key_parent::save_unique_constraint_name(char **buff_p)
@@ -307,8 +308,8 @@ void Foreign_key_parent::save_unique_con
 
 
 /**
-   Get flags for foreign key description in .FRM which are specific for
-   description in child table.
+  Get flags for foreign key description in .FRM which are specific for
+  description in child table.
 */
 
 char Foreign_key_child::get_additional_flags()
@@ -318,7 +319,7 @@ char Foreign_key_child::get_additional_f
 
 
 /**
-   Save match option of the foreign key in .FRM of child table.
+  Save match option of the foreign key in .FRM of child table.
 */
 
 void Foreign_key_child::save_match_opt(char **buff_p)
@@ -331,8 +332,8 @@ void Foreign_key_child::save_match_opt(c
 
 
 /**
-   Get table database and name of which should be saved in the description
-   of foreign key in child table.
+  Get table database and name of which should be saved in the description
+  of foreign key in child table.
 */
 
 TABLE_LIST* Foreign_key_child::get_table_for_frm()
@@ -342,9 +343,9 @@ TABLE_LIST* Foreign_key_child::get_table
 
 
 /**
-   Save name of the unique constraint of the parent table participating
-   in the foreign key in the child .FRM. Necessary to properly fill
-   UNIQUE_CONSTRAINT_NAME field of I_S.TABLE_CONSTRAINTS view.
+  Save name of the unique constraint of the parent table participating
+  in the foreign key in the child .FRM. Necessary to properly fill
+  UNIQUE_CONSTRAINT_NAME field of I_S.TABLE_CONSTRAINTS view.
 */
 
 void Foreign_key_child::save_unique_constraint_name(char **buff_p)
@@ -356,17 +357,17 @@ void Foreign_key_child::save_unique_cons
 
 
 /**
-   Save descriptions of foreign keys in the .FRM file.
+  Save descriptions of foreign keys in the .FRM file.
 
-   @param thd              Thread context.
-   @param file             Descriptor of open .FRM file.
-   @param fkey_list        List of foreign keys for which this table is child.
-   @param parent_fkey_list List of foreign keys for which this table is parent.
-   @param total_length     Length of the descriptions which was given by
-                           fk_get_frm_section_length() function.
+  @param thd              Thread context.
+  @param file             Descriptor of open .FRM file.
+  @param fkey_list        List of foreign keys for which this table is child.
+  @param parent_fkey_list List of foreign keys for which this table is parent.
+  @param total_length     Length of the descriptions which was given by
+                          fk_get_frm_section_length() function.
 
-   @retval TRUE  in case of error.
-   @retval FALSE otherwise.
+  @retval TRUE  in case of error.
+  @retval FALSE otherwise.
 */
 
 bool fk_save_to_frm_section(THD *thd, File file,
@@ -422,18 +423,18 @@ bool fk_save_to_frm_section(THD *thd, Fi
 
 
 /**
-   Restore foreign key object from its description in .FRM file.
+  Restore foreign key object from its description in .FRM file.
 
-   @param thd      [in]     Thread context.
-   @param share    [in]     Share of the table which .FRM is being read and
-                            which memory root will be used for allocating
-                            auxiliary objects for foreign key.
-   @param buff_p   [in/out] On entering routine should point to the beginning
-                            of FK description in the buffer, on leaving it will
-                            point to the position right after this description.
+  @param thd      [in]     Thread context.
+  @param share    [in]     Share of the table which .FRM is being read and
+                           which memory root will be used for allocating
+                           auxiliary objects for foreign key.
+  @param buff_p   [in/out] On entering routine should point to the beginning
+                           of FK description in the buffer, on leaving it will
+                           point to the position right after this description.
 
-   @retval FALSE  Success.
-   @retval TRUE   Failure.
+  @retval FALSE  Success.
+  @retval TRUE   Failure.
 */
 
 bool Foreign_key_share::restore_from_frm(THD *thd, TABLE_SHARE *share,
@@ -539,8 +540,8 @@ bool Foreign_key_share::restore_from_frm
 
 
 /**
-   Restore information about foreign key which was saved in .FRM as flags
-   specific for foreign key description in child table.
+  Restore information about foreign key which was saved in .FRM as flags
+  specific for foreign key description in child table.
 */
 
 void Foreign_key_child_share::restore_additional_flags(char flags)
@@ -550,8 +551,8 @@ void Foreign_key_child_share::restore_ad
 
 
 /**
-   Restore value of foreign key's match option from its description
-   in .FRM of child table.
+  Restore value of foreign key's match option from its description
+  in .FRM of child table.
 */
 
 void Foreign_key_child_share::restore_match_opt(const char **buff_p)
@@ -562,8 +563,8 @@ void Foreign_key_child_share::restore_ma
 
 
 /**
-   Set name and database of another (i.e. parent) table participating in
-   foreign key constraint from its description in child table.
+  Set name and database of another (i.e. parent) table participating in
+  foreign key constraint from its description in child table.
 */
 
 void Foreign_key_child_share::set_table_from_frm(LEX_STRING &db, LEX_STRING &table_name)
@@ -574,9 +575,9 @@ void Foreign_key_child_share::set_table_
 
 
 /**
-   Indicates if description of foreign key in .FRM contains
-   name of unique constraint in parent table participating
-   in the foreign key.
+  Indicates if description of foreign key in .FRM contains
+  name of unique constraint in parent table participating
+  in the foreign key.
 */
 
 bool Foreign_key_child_share::has_unique_constraint_name()
@@ -586,8 +587,8 @@ bool Foreign_key_child_share::has_unique
 
 
 /**
-   Restore name of unique constraint in the parent table which
-   participates in the foreign key from the child .FRM.
+  Restore name of unique constraint in the parent table which
+  participates in the foreign key from the child .FRM.
 */
 
 void
@@ -600,8 +601,8 @@ restore_unique_constraint_name(const cha
 
 
 /**
-   Restore information about foreign key which was saved in .FRM as flags
-   specific for foreign key description in parent table.
+  Restore information about foreign key which was saved in .FRM as flags
+  specific for foreign key description in parent table.
 */
 
 void Foreign_key_parent_share::restore_additional_flags(char flags)
@@ -610,9 +611,9 @@ void Foreign_key_parent_share::restore_a
 
 
 /**
-   Restore value of foreign key's match option from its description
-   in .FRM of parent table (Does nothing as we don't store this
-   information in foreign key description for the parent table).
+  Restore value of foreign key's match option from its description
+  in .FRM of parent table (Does nothing as we don't store this
+  information in foreign key description for the parent table).
 */
 
 void
@@ -622,8 +623,8 @@ Foreign_key_parent_share::restore_match_
 
 
 /**
-   Set name and database of another (i.e. child) table participating in
-   foreign key constraint from its description in parent table.
+  Set name and database of another (i.e. child) table participating in
+  foreign key constraint from its description in parent table.
 */
 
 void Foreign_key_parent_share::set_table_from_frm(LEX_STRING &db, LEX_STRING &table_name)
@@ -634,9 +635,9 @@ void Foreign_key_parent_share::set_table
 
 
 /**
-   Indicates if description of foreign key in .FRM contains
-   name of unique constraint in parent table participating
-   in the foreign key.
+  Indicates if description of foreign key in .FRM contains
+  name of unique constraint in parent table participating
+  in the foreign key.
 */
 
 bool Foreign_key_parent_share::has_unique_constraint_name()
@@ -646,9 +647,9 @@ bool Foreign_key_parent_share::has_uniqu
 
 
 /**
-   Restore name of unique constraint in the parent table which participates
-   in the foreign key from the parent .FRM (Does nothing as we don't store
-   this information in .FRM of parent).
+  Restore name of unique constraint in the parent table which participates
+  in the foreign key from the parent .FRM (Does nothing as we don't store
+  this information in .FRM of parent).
 */
 
 void
@@ -659,17 +660,17 @@ restore_unique_constraint_name(const cha
 
 
 /**
-   Restore foreign keys for the table their description in the .FRM.
+  Restore foreign keys for the table their description in the .FRM.
 
-   @param thd      [in]     Thread context.
-   @param share    [in]     Share of the table FKs for which should be restored.
-   @param buff_p   [in/out] On entering routine should point to the beginning of
-                            FKs section in the buffer, on leaving it will point
-                            to the position right after this section.
-   @param buff_end [in]     Pointer to the end of buffer containing .FRM data.
+  @param thd      [in]     Thread context.
+  @param share    [in]     Share of the table FKs for which should be restored.
+  @param buff_p   [in/out] On entering routine should point to the beginning of
+                           FKs section in the buffer, on leaving it will point
+                           to the position right after this section.
+  @param buff_end [in]     Pointer to the end of buffer containing .FRM data.
 
-   @retval TRUE  in case of error.
-   @retval FALSE otherwise.
+  @retval TRUE  in case of error.
+  @retval FALSE otherwise.
 */
 
 bool fk_restore_from_frm_section(THD *thd, TABLE_SHARE *share,
@@ -717,7 +718,7 @@ bool fk_restore_from_frm_section(THD *th
 
 
 /**
-   Names of referential actions in order corresponding to enum_fk_option enum.
+  Names of referential actions in order corresponding to enum_fk_option enum.
 */
 
 const LEX_STRING fk_ref_action_names[]= { {NULL, 0},
@@ -728,10 +729,10 @@ const LEX_STRING fk_ref_action_names[]= 
                                           C_STRING_WITH_LEN("SET DEFAULT")};
 
 /**
-   Names of match options in order corresponding to enum_fk_match_opt enum.
+  Names of match options in order corresponding to enum_fk_match_opt enum.
 
-   @note Contains NONE for MATCH SIMPLE as it is value which is show
-         for this match option in I_S table.
+  @note Contains NONE for MATCH SIMPLE as it is value which is show
+        for this match option in I_S table.
 */
 
 const LEX_STRING fk_match_type_names[]= { {NULL, 0},
@@ -741,10 +742,10 @@ const LEX_STRING fk_match_type_names[]= 
 
 
 /**
-   Get CREATE TABLE clause for the foreign key.
+  Get CREATE TABLE clause for the foreign key.
 
-   @param thd [in]     Thread context.
-   @param str [in/out] String to which clause should be appended.
+  @param thd [in]     Thread context.
+  @param str [in/out] String to which clause should be appended.
 */
 
 void Foreign_key_child_share::get_create_statement_clause(THD *thd, String *str)
@@ -822,13 +823,13 @@ void Foreign_key_child_share::get_create
 
 
 /**
-   Get CREATE TABLE clause describing column foreign key for one
-   of table columns.
+  Get CREATE TABLE clause describing column foreign key for one
+  of table columns.
 
-   @param thd          Thread context.
-   @param str [in/out] String to which clause should be appended.
-   @param table        TABLE object for the table in question.
-   @param field_name   Name of the column.
+  @param thd          Thread context.
+  @param str [in/out] String to which clause should be appended.
+  @param table        TABLE object for the table in question.
+  @param field_name   Name of the column.
 */
 
 void fk_get_column_constraint_for_create(THD *thd, String *str, TABLE *table,
@@ -850,12 +851,12 @@ void fk_get_column_constraint_for_create
 
 
 /**
-   Get CREATE TABLE clauses describing all foreign keys for the table
-   which were created as table constraints.
+  Get CREATE TABLE clauses describing all foreign keys for the table
+  which were created as table constraints.
 
-   @param thd          Thread context.
-   @param str [in/out] String to which clauses should be appended.
-   @param table        TABLE object for the table in question.
+  @param thd          Thread context.
+  @param str [in/out] String to which clauses should be appended.
+  @param table        TABLE object for the table in question.
 */
 
 void fk_get_table_constraints_for_create(THD *thd, String *str, TABLE *table)
@@ -869,13 +870,13 @@ void fk_get_table_constraints_for_create
 
 
 /**
-   Generate name for foreign key without an explicitly specified name.
+  Generate name for foreign key without an explicitly specified name.
 
-   @param thd        Thread context.
-   @param table_name Name of the table to be created/altered.
+  @param thd        Thread context.
+  @param table_name Name of the table to be created/altered.
 
-   @retval FALSE Success
-   @retval TRUE  Error (OOM).
+  @retval FALSE Success
+  @retval TRUE  Error (OOM).
 */
 
 bool Foreign_key_child::generate_name_if_needed(THD *thd,
@@ -944,14 +945,14 @@ bool Foreign_key_child::generate_name_if
 
 
 /**
-   Generate names for foreign key constraints without explicit names.
+  Generate names for foreign key constraints without explicit names.
 
-   @param thd        Thread context.
-   @param table_name Name of the table to be created/altered.
-   @param fkey_list  List of foreign keys.
+  @param thd        Thread context.
+  @param table_name Name of the table to be created/altered.
+  @param fkey_list  List of foreign keys.
 
-   @retval FALSE Success
-   @retval TRUE  Error (OOM).
+  @retval FALSE Success
+  @retval TRUE  Error (OOM).
 */
 
 bool fk_generate_constraint_names(THD *thd, const char *table_name,
@@ -968,21 +969,21 @@ bool fk_generate_constraint_names(THD *t
 
 
 /**
-   For each foreign key mentioned in CREATE/ALTER table specification, add
-   an entry to the list of foreign key names to acquire exclusive metadata
-   locks on.
+  For each foreign key mentioned in CREATE/ALTER table specification, add
+  an entry to the list of foreign key names to acquire exclusive metadata
+  locks on.
 
-   @param thd        Thread context.
-   @param lex        LEX for the statement
-   @param fkey_list  List of foreign keys
+  @param thd        Thread context.
+  @param lex        LEX for the statement
+  @param fkey_list  List of foreign keys
 
-   @note Keep in mind that elements added by this function will reference
-         to elements of source list and are allocated on current memory root.
+  @note Keep in mind that elements added by this function will reference
+        to elements of source list and are allocated on current memory root.
 
-   @sa class Query_tables_list
+  @sa class Query_tables_list
 
-   @retval FALSE Success
-   @retval TRUE  Error (OOM).
+  @retval FALSE Success
+  @retval TRUE  Error (OOM).
 */
 
 bool fk_add_constraint_names_to_lock(THD *thd, LEX *lex,
@@ -1010,12 +1011,12 @@ bool fk_add_constraint_names_to_lock(THD
 
 
 /**
-   Structure representing contents of .CNS file which are employed to
-   implement database wide namespace for constraint names. This structure
-   is empty since at this point we use only the fact that .CNS file exists
-   or doesn't exist and introduction of additional data to the contents
-   (e.g. name of the table with which this constraint is associated) might
-   our life in future (e.g. implementing renaming of child tables).
+  Structure representing contents of .CNS file which are employed to
+  implement database wide namespace for constraint names. This structure
+  is empty since at this point we use only the fact that .CNS file exists
+  or doesn't exist and introduction of additional data to the contents
+  (e.g. name of the table with which this constraint is associated) might
+  our life in future (e.g. implementing renaming of child tables).
 */
 
 struct st_constraint_name_file
@@ -1024,7 +1025,7 @@ struct st_constraint_name_file
 
 
 /**
-   File type constant for .CNS files.
+  File type constant for .CNS files.
 */
 
 static const LEX_STRING constraint_name_file_type=
@@ -1032,14 +1033,14 @@ static const LEX_STRING constraint_name_
 
 
 /**
-   String with extension of .CNS files.
+  String with extension of .CNS files.
 */
 
 const char * const CNS_EXT= ".CNS";
 
 
 /**
-   Description of contents of .CNS file (they are empty now).
+  Description of contents of .CNS file (they are empty now).
 */
 
 static File_option constraint_name_file_parameters[]=
@@ -1049,13 +1050,13 @@ static File_option constraint_name_file_
 
 
 /**
-   Check if constraint with such name exists in database.
+  Check if constraint with such name exists in database.
 
-   @param db    Name of database
-   @param name  Name of constraint
+  @param db    Name of database
+  @param name  Name of constraint
 
-   @retval TRUE   If constraint exists.
-   @retval FALSE  Otherwise.
+  @retval TRUE   If constraint exists.
+  @retval FALSE  Otherwise.
 */
 
 bool fk_check_if_constraint_name_exists(const char *db, const char *name)
@@ -1069,14 +1070,14 @@ bool fk_check_if_constraint_name_exists(
 
 
 /**
-   Create .CNS file for the constraint name and thus mark it as used
-   in this database.
+  Create .CNS file for the constraint name and thus mark it as used
+  in this database.
 
-   @param db    Name of database.
-   @param name  Name of constraint.
+  @param db    Name of database.
+  @param name  Name of constraint.
 
-   @retval FALSE Success.
-   @retval TRUE  Error.
+  @retval FALSE Success.
+  @retval TRUE  Error.
 */
 
 static bool fk_create_constraint_name(const char *db, const char *name)
@@ -1097,18 +1098,18 @@ static bool fk_create_constraint_name(co
 
 
 /**
-   Create .CNS files for the list of constraints in the database and thus
-   mark their names as occupied.
+  Create .CNS files for the list of constraints in the database and thus
+  mark their names as occupied.
 
-   @param fkey_list  List of foreign keys.
-   @param db         Name of database.
+  @param fkey_list  List of foreign keys.
+  @param db         Name of database.
 
-   @note This function assumes that names of constraints are not occupied.
-         If .CNS file for some of constraints already exists it will
-         silently overwrite it instead of reporting error.
+  @note This function assumes that names of constraints are not occupied.
+        If .CNS file for some of constraints already exists it will
+        silently overwrite it instead of reporting error.
 
-   @retval FALSE Success.
-   @retval TRUE  Error.
+  @retval FALSE Success.
+  @retval TRUE  Error.
 */
 
 bool fk_create_constraint_names(List<Foreign_key_child> &fkey_list,
@@ -1135,13 +1136,13 @@ err:
 
 
 /**
-   Delete .CNS file for constraint name and mark it as unoccupied.
+  Delete .CNS file for constraint name and mark it as unoccupied.
 
-   @param db    Name of database.
-   @param name  Name of constraint.
+  @param db    Name of database.
+  @param name  Name of constraint.
 
-   @retval FALSE Success.
-   @retval TRUE  Error.
+  @retval FALSE Success.
+  @retval TRUE  Error.
 */
 
 bool fk_drop_constraint_name(const char *db, const char *name)
@@ -1153,19 +1154,19 @@ bool fk_drop_constraint_name(const char 
 
 
 /**
-   Delete .CNS files for all constraints associated with table and
-   thus mark their names as unoccupied.
+  Delete .CNS files for all constraints associated with table and
+  thus mark their names as unoccupied.
 
-   @param thd    Thread context
-   @param table  Table for which constraints should be deleted.
+  @param thd    Thread context
+  @param table  Table for which constraints should be deleted.
 
-   @note This is auxiliary function which we temporarily employ in order
-         to be able to remove all .CNS files when dropping table. We
-         might change it signature or even completely get rid of it on
-         later milestones of WL#148.
+  @note This is auxiliary function which we temporarily employ in order
+        to be able to remove all .CNS files when dropping table. We
+        might change it signature or even completely get rid of it on
+        later milestones of WL#148.
 
-   @retval FALSE Success.
-   @retval TRUE  Error.
+  @retval FALSE Success.
+  @retval TRUE  Error.
 */
 
 bool fk_drop_all_constraint_names_for_table(THD *thd, TABLE_LIST *table)
@@ -1209,14 +1210,14 @@ bool fk_drop_all_constraint_names_for_ta
 
 
 /**
-   Find definition of the foreign key column in the list of table's
-   column definitions.
+  Find definition of the foreign key column in the list of table's
+  column definitions.
 
-   @param col          Column which definition should be found
-   @param create_list  List of column definitions
+  @param col          Column which definition should be found
+  @param create_list  List of column definitions
 
-   @retval non-0 - Pointer to Create_field object describing column
-   @retval 0     - Column was not found
+  @retval non-0 - Pointer to Create_field object describing column
+  @retval 0     - Column was not found
 */
 
 static Create_field *
@@ -1236,18 +1237,18 @@ fk_find_column_def(Key_part_spec *col, L
 
 
 /**
-   Check if the column participates in the foreign key more than once.
+  Check if the column participates in the foreign key more than once.
 
-   @param col     Column to be checked
-   @param columns List of columns against which check should be performed
+  @param col     Column to be checked
+  @param columns List of columns against which check should be performed
 
-   @note This function relies on that it is going to be called for all
-         columns of the foreign key and so it can search for duplicates
-         only among columns which precede in the foreign key column
-         being checked.
+  @note This function relies on that it is going to be called for all
+        columns of the foreign key and so it can search for duplicates
+        only among columns which precede in the foreign key column
+        being checked.
 
-   @retval TRUE  - if column occurs more than once.
-   @retval FALSE - if column occurs only once.
+  @retval TRUE  - if column occurs more than once.
+  @retval FALSE - if column occurs only once.
 */
 
 static bool fk_column_has_dup(Key_part_spec *col, List<Key_part_spec> &columns)
@@ -1267,14 +1268,14 @@ static bool fk_column_has_dup(Key_part_s
 
 
 /**
-   Perform checks for child and parent columns of the foreign key.
+  Perform checks for child and parent columns of the foreign key.
 
-   @param fkey               Foreign key which columns should be checked.
-   @param alter_info         Alter_info describing child table.
-   @param parent_alter_info  Alter_info describing parent table.
+  @param fkey               Foreign key which columns should be checked.
+  @param alter_info         Alter_info describing child table.
+  @param parent_alter_info  Alter_info describing parent table.
 
-   @retval TRUE  - Failure
-   @retval FALSE - Success
+  @retval TRUE  - Failure
+  @retval FALSE - Success
 */
 
 static bool fk_check_columns(Foreign_key_child *fkey, Alter_info *alter_info,
@@ -1399,14 +1400,14 @@ static bool fk_check_columns(Foreign_key
 
 
 /**
-   Check if foreign key has a child columns which is also child column in
-   another foreign key on this table and emit appropriate error message.
+  Check if foreign key has a child columns which is also child column in
+  another foreign key on this table and emit appropriate error message.
 
-   @param fkey    Foreign key which columns should be checked.
-   @param fk_list List of foreign keys for the table.
+  @param fkey    Foreign key which columns should be checked.
+  @param fk_list List of foreign keys for the table.
 
-   @retval TRUE  Overlapping foreign key was found and error was emitted.
-   @retval FALSE There are no overlapping foreign keys.
+  @retval TRUE  Overlapping foreign key was found and error was emitted.
+  @retval FALSE There are no overlapping foreign keys.
 */
 
 static bool fk_check_child_columns_overlap(Foreign_key_child *fkey,
@@ -1447,17 +1448,17 @@ static bool fk_check_child_columns_overl
 
 
 /**
-   Perform all checks before creation of a foreign key (except those
-   that involve changes to foreign key or table definition).
+  Perform all checks before creation of a foreign key (except those
+  that involve changes to foreign key or table definition).
 
-   @param thd         Thread context
-   @param fkey        Foreign key to be created.
-   @param create_info HA_CREATE_INFO for table to be created.
-   @param alter_info  Alter_indo for table to be created.
-   @param file        Handler for table to be created.
+  @param thd         Thread context
+  @param fkey        Foreign key to be created.
+  @param create_info HA_CREATE_INFO for table to be created.
+  @param alter_info  Alter_indo for table to be created.
+  @param file        Handler for table to be created.
 
-   @retval FALSE  Success, all checks passed.
-   @retval TRUE   Some error discovered.
+  @retval FALSE  Success, all checks passed.
+  @retval TRUE   Some error discovered.
 */
 
 bool fk_check_constraint_added(THD *thd, Foreign_key_child *fkey,
@@ -1676,15 +1677,15 @@ bool fk_check_constraint_added(THD *thd,
 
 
 /**
-   Find unique constraint which participates in the foreign key being
-   created. Also add supporting index for this foreign key.
+  Find unique constraint which participates in the foreign key being
+  created. Also add supporting index for this foreign key.
 
-   @param thd         Thread context.
-   @param fkey        Foreign key to be created.
-   @param alter_info  Alter_info describing table being created.
+  @param thd         Thread context.
+  @param fkey        Foreign key to be created.
+  @param alter_info  Alter_info describing table being created.
 
-   @retval FALSE Success
-   @retval TRUE  Error
+  @retval FALSE Success
+  @retval TRUE  Error
 */
 
 bool fk_find_unique_and_add_supporting_key(THD *thd, Foreign_key_child *fkey,
@@ -1772,21 +1773,21 @@ bool fk_find_unique_and_add_supporting_k
 
 
 /**
-   In --foreign-key-all-engines mode check if one of two keys was generated
-   as supporting for foreign key constraint and can be removed since second
-   key can also serve as supporting for the same foreign key.
-
-   @param key   The first key
-   @param key2  The second key
-
-   @note In --foreign-key-all-engines mode (unlike in old mode) supporting
-         key should contain exactly the same columns as a foreign key.
-         So we can remove one of the keys only if the second key contains
-         exactly the same columns.
-
-   @retval -1 - The first key is generated and can be removed
-   @retval +1 - The second key is generated and can be removed
-   @retval 0  - Neither of keys should be removed
+  In --foreign-key-all-engines mode check if one of two keys was generated
+  as supporting for foreign key constraint and can be removed since second
+  key can also serve as supporting for the same foreign key.
+
+  @param key   The first key
+  @param key2  The second key
+
+  @note In --foreign-key-all-engines mode (unlike in old mode) supporting
+        key should contain exactly the same columns as a foreign key.
+        So we can remove one of the keys only if the second key contains
+        exactly the same columns.
+
+  @retval -1 - The first key is generated and can be removed
+  @retval +1 - The second key is generated and can be removed
+  @retval 0  - Neither of keys should be removed
 */
 
 int fk_check_if_key_is_generated_and_redundant(Key *a, Key *b)
@@ -1824,20 +1825,20 @@ int fk_check_if_key_is_generated_and_red
 
 
 /**
-   Convert list of columns names to a list of Key_part_spec objects
-   which can be used for creation of foreign key using this columns.
+  Convert list of columns names to a list of Key_part_spec objects
+  which can be used for creation of foreign key using this columns.
 
-   @param colnames [in]      List of column names to be converted
-   @param cols     [in/out]  Initially empty list of Key_part_spec objects
-                             to be filled according to colnames list
-   @param mem_root [in]      Memory root on which objects shoudl be allocated
-
-   @note Result list will contain references to the strings from original
-         list and thus lifetime of the new list is limited by lifetime of
-         original one.
+  @param colnames [in]      List of column names to be converted
+  @param cols     [in/out]  Initially empty list of Key_part_spec objects
+                            to be filled according to colnames list
+  @param mem_root [in]      Memory root on which objects shoudl be allocated
+
+  @note Result list will contain references to the strings from original
+        list and thus lifetime of the new list is limited by lifetime of
+        original one.
 
-   @retval TRUE   An error occured (OOM).
-   @retval FALSE  Success.
+  @retval TRUE   An error occured (OOM).
+  @retval FALSE  Success.
 */
 
 static bool fk_colnames_to_key_part_spec(List<LEX_STRING> &colnames,
@@ -1859,19 +1860,19 @@ static bool fk_colnames_to_key_part_spec
 
 
 /**
-   Given object representing foreign key in the share of parent table
-   create Foreign_key_parent instance describing it, which can be used
-   for saving information about this foreign key into .FRM (of the
-   parent table) during ALTER TABLE.
-
-   @param  mem_root Memory root to be used for allocating new object.
-
-   @note Since created object will contain references to the memory and
-         members of original object its life-time is limited by lifetime
-         of the original object.
+  Given object representing foreign key in the share of parent table
+  create Foreign_key_parent instance describing it, which can be used
+  for saving information about this foreign key into .FRM (of the
+  parent table) during ALTER TABLE.
+
+  @param  mem_root Memory root to be used for allocating new object.
+
+  @note Since created object will contain references to the memory and
+        members of original object its life-time is limited by lifetime
+        of the original object.
 
-   @retval non-NULL  Pointer to new Foreign_key_parent instance.
-   @retval NULL      OOM occurred.
+  @retval non-NULL  Pointer to new Foreign_key_parent instance.
+  @retval NULL      OOM occurred.
 */
 
 Foreign_key_parent*
@@ -1900,20 +1901,20 @@ Foreign_key_parent_share::make_foreign_k
 
 
 /**
-   Given object representing foreign key in the share of child table
-   create Foreign_key_child instance describing it, which can be used
-   for saving information about this foreign key into .FRM during
-   ALTER TABLE.
-
-   @param  mem_root   Memory root to be used for allocating new object.
-   @param  child_tab  Table list element for child table.
-
-   @note Since created object will contain references to the memory and
-         members of original object its life-time is limited by lifetime
-         of the original object.
+  Given object representing foreign key in the share of child table
+  create Foreign_key_child instance describing it, which can be used
+  for saving information about this foreign key into .FRM during
+  ALTER TABLE.
+
+  @param  mem_root   Memory root to be used for allocating new object.
+  @param  child_tab  Table list element for child table.
+
+  @note Since created object will contain references to the memory and
+        members of original object its life-time is limited by lifetime
+        of the original object.
 
-   @retval non-NULL  Pointer to new Foreign_key_child instance.
-   @retval NULL      OOM occurred.
+  @retval non-NULL  Pointer to new Foreign_key_child instance.
+  @retval NULL      OOM occurred.
 */
 
 Foreign_key_child*
@@ -1946,11 +1947,11 @@ Foreign_key_child_share::make_foreign_ke
 
 
 /**
-   Mark columns from the list as used in the set of used table columns.
+  Mark columns from the list as used in the set of used table columns.
 
-   @param columns  List of column names
-   @param share    Table's share
-   @param bitmap   Set of used columns
+  @param columns  List of column names
+  @param share    Table's share
+  @param bitmap   Set of used columns
 */
 
 static void fk_colnames_to_set(List<LEX_STRING> &columns, TABLE_SHARE *share,
@@ -1968,14 +1969,14 @@ static void fk_colnames_to_set(List<LEX_
 
 
 /**
-   Set up list of share's Field objects corresponding to list of column names.
+  Set up list of share's Field objects corresponding to list of column names.
 
-   @param columns  [in]  List of column names
-   @param share    [in]  Table's share
-   @param fld_list [out] List of share's Field objects for columns
+  @param columns  [in]  List of column names
+  @param share    [in]  Table's share
+  @param fld_list [out] List of share's Field objects for columns
 
-   @retval FALSE  Success.
-   @retval TRUE   Failure (OOM or data-dictionary inconsistency).
+  @retval FALSE  Success.
+  @retval TRUE   Failure (OOM or data-dictionary inconsistency).
 */
 
 static bool
@@ -1996,21 +1997,21 @@ fk_colnames_to_field_list(List<LEX_STRIN
 
 
 /**
-   Initialize set of columns of the table participating in the foreign key
-   and list of fields for them.
+  Initialize set of columns of the table participating in the foreign key
+  and list of fields for them.
 
-   @note This set is used by optimization in fk_add_tables_for_fks()
-         function for determining if foreign key is affected by the
-         update operation on the table.
-   @note This method is invoked at the end of the process of TABLE_SHARE
-         initialization (when we have properly set-up structures for
-         looking up fields by names).
+  @note This set is used by optimization in fk_add_tables_for_fks()
+        function for determining if foreign key is affected by the
+        update operation on the table.
+  @note This method is invoked at the end of the process of TABLE_SHARE
+        initialization (when we have properly set-up structures for
+        looking up fields by names).
 
-   @param share Share of the table for which this Foreign_key_share object
-                represents a foreign key.
+  @param share Share of the table for which this Foreign_key_share object
+               represents a foreign key.
 
-   @retval FALSE  Success.
-   @retval TRUE   Failure (OOM).
+  @retval FALSE  Success.
+  @retval TRUE   Failure (OOM).
 */
 
 bool Foreign_key_share::init_column_set(TABLE_SHARE *share)
@@ -2042,10 +2043,10 @@ bool Foreign_key_share::init_column_set(
 
 
 /**
-   For the object respesenting foreign key in a table share get list
-   of columns in this table which participate in this foreign key.
-   (in case of Foreign_key_child_share it is list of referencing
-   columns).
+  For the object respesenting foreign key in a table share get list
+  of columns in this table which participate in this foreign key.
+  (in case of Foreign_key_child_share it is list of referencing
+  columns).
 */
 
 List<LEX_STRING>& Foreign_key_child_share::get_table_columns()
@@ -2055,10 +2056,10 @@ List<LEX_STRING>& Foreign_key_child_shar
 
 
 /**
-   For the object respesenting foreign key in a table share get list
-   of columns in this table which participate in this foreign key.
-   (in case of Foreign_key_parent_share it is list of referenced
-   columns).
+  For the object respesenting foreign key in a table share get list
+  of columns in this table which participate in this foreign key.
+  (in case of Foreign_key_parent_share it is list of referenced
+  columns).
 */
 
 List<LEX_STRING>& Foreign_key_parent_share::get_table_columns()
@@ -2068,15 +2069,15 @@ List<LEX_STRING>& Foreign_key_parent_sha
 
 
 /**
-   Initialize sets of the table columns participating in foreign keys
-   for all table's foreign keys.
+  Initialize sets of the table columns participating in foreign keys
+  for all table's foreign keys.
 
-   @sa Foreign_key_share::column_set/init_column_set().
+  @sa Foreign_key_share::column_set/init_column_set().
 
-   @param share Table's share.
+  @param share Table's share.
 
-   @retval FALSE  Success.
-   @retval TRUE   Failure (OOM).
+  @retval FALSE  Success.
+  @retval TRUE   Failure (OOM).
 */
 
 bool fk_init_column_sets(TABLE_SHARE *share)
@@ -2097,22 +2098,22 @@ bool fk_init_column_sets(TABLE_SHARE *sh
 
 
 /**
-   The role in which this foreign key is used in the current statement.
+  The role in which this foreign key is used in the current statement.
 
-   When generating the set of tables to prelock, we also construct a
-   unique set of all foreign keys invoked by the statement, directly
-   or indirectly.
-   A foreign key may be present several times in this set, but not more
-   than 3: one for each role enumerated below (so actually it is set
-   of <key, role> pairs).
-   Addition of a new combination <key, role> happens only if it is not
-   yet present in the set. When adding a combination to the set, we also
-   add TABLE_LIST elements for involved tables to the list of tables to
-   prelock.
-   In case of FK_ROLE_CHILD_INSERT, the parent table is added with READ
-   lock. In case of FK_ROLE_PARENT_UPDATE or FK_ROLE_PARENT_DELETE, the
-   child table with WRITE lock (to perform ON UPDATE/DELETE CASCADE/SET
-   NULL/SET DEFAULT).
+  When generating the set of tables to prelock, we also construct a
+  unique set of all foreign keys invoked by the statement, directly
+  or indirectly.
+  A foreign key may be present several times in this set, but not more
+  than 3: one for each role enumerated below (so actually it is set
+  of <key, role> pairs).
+  Addition of a new combination <key, role> happens only if it is not
+  yet present in the set. When adding a combination to the set, we also
+  add TABLE_LIST elements for involved tables to the list of tables to
+  prelock.
+  In case of FK_ROLE_CHILD_INSERT, the parent table is added with READ
+  lock. In case of FK_ROLE_PARENT_UPDATE or FK_ROLE_PARENT_DELETE, the
+  child table with WRITE lock (to perform ON UPDATE/DELETE CASCADE/SET
+  NULL/SET DEFAULT).
 */
 
 enum fk_role {FK_ROLE_CHILD_INSERT= 0, FK_ROLE_PARENT_UPDATE,
@@ -2120,20 +2121,20 @@ enum fk_role {FK_ROLE_CHILD_INSERT= 0, F
 
 
 /**
-   Add foreign key constraint + role combination to the set of "stored
-   routines" used by statement.
+  Add foreign key constraint + role combination to the set of "stored
+  routines" used by statement.
 
-   @note By doing this we ensure that each foreign key/role pair is
-         handled by prelocking algorithm only once for each statement.
+  @note By doing this we ensure that each foreign key/role pair is
+        handled by prelocking algorithm only once for each statement.
 
-   @param thd   Thread context.
-   @param lex   LEX of this statement
-   @param fk    Foreign key
-   @param role  Role of the foreign key to be added
-
-   @retval TRUE  - constraint/role pair was added.
-   @retval FALSE - constraint/role pair was not added since
-                   it is already present in the set.
+  @param thd   Thread context.
+  @param lex   LEX of this statement
+  @param fk    Foreign key
+  @param role  Role of the foreign key to be added
+
+  @retval TRUE  - constraint/role pair was added.
+  @retval FALSE - constraint/role pair was not added since
+                  it is already present in the set.
 */
 
 static bool fk_add_used_fk(THD *thd, LEX *lex, const char *db,
@@ -2151,23 +2152,23 @@ static bool fk_add_used_fk(THD *thd, LEX
 
 
 /**
-   Add table needed for foreign key constraint check or action to the
-   table list of statement.
+  Add table needed for foreign key constraint check or action to the
+  table list of statement.
 
-   @param thd             Thread context
-   @param lex             LEX for the statement
-   @param tab             TABLE_LIST for the table from the foreign key
-                          description
-   @param lock_type       Type of lock
-   @param trg_event_map   Bitmap with operations to be performed on table
-   @param belong_to_view  Uppermost view which uses this foreign key
-                          (0 if foreign key is not used by view).
-   @param columns         Pointer to the list of columns which are going
-                          to be updated by the action (0 - if check/action
-                          won't involve update).
+  @param thd             Thread context
+  @param lex             LEX for the statement
+  @param tab             TABLE_LIST for the table from the foreign key
+                         description
+  @param lock_type       Type of lock
+  @param trg_event_map   Bitmap with operations to be performed on table
+  @param belong_to_view  Uppermost view which uses this foreign key
+                         (0 if foreign key is not used by view).
+  @param columns         Pointer to the list of columns which are going
+                         to be updated by the action (0 - if check/action
+                         won't involve update).
 
-   @retval FALSE Success.
-   @retval TRUE  Failure (OOM).
+  @retval FALSE Success.
+  @retval TRUE  Failure (OOM).
 */
 
 static bool fk_add_table_to_table_list(THD *thd, LEX *lex,
@@ -2225,16 +2226,16 @@ static bool fk_add_table_to_table_list(T
 
 
 /**
-   Process all foreign key constraints which are going to be involved
-   in operation performed on the table and if needed add appropriate
-   tables to the table list.
-
-   @param thd    Thread context
-   @param lex    LEX of the statement
-   @param table  Element of table list to be processed
+  Process all foreign key constraints which are going to be involved
+  in operation performed on the table and if needed add appropriate
+  tables to the table list.
+
+  @param thd    Thread context
+  @param lex    LEX of the statement
+  @param table  Element of table list to be processed
 
-   @retval FALSE - Success
-   @retval TRUE  - Failure (OOM)
+  @retval FALSE - Success
+  @retval TRUE  - Failure (OOM)
 */
 
 bool fk_add_tables_for_fks(THD *thd, LEX *lex, TABLE_LIST *table)

=== modified file 'sql/fk_dd.h'
--- a/sql/fk_dd.h	2008-12-08 19:13:22 +0000
+++ b/sql/fk_dd.h	2008-12-09 12:41:08 +0000
@@ -37,10 +37,10 @@ bool fk_generate_constraint_names(THD *t
 
 
 /**
-   Represents foreign key name in the list of foreign key names on
-   which we want to obtain metadata locks.
+  Represents foreign key name in the list of foreign key names on
+  which we want to obtain metadata locks.
 
-   @sa class Query_tables_list.
+  @sa class Query_tables_list.
 */
 
 struct Foreign_key_name_entry

Thread
bzr commit into mysql-6.1-fk branch (dlenev:2689) WL#148Dmitry Lenev9 Dec