#include <sql_class.h>
Inheritance diagram for Key:


Public Types | |
| enum | Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY } |
Public Member Functions | |
| Key (enum Keytype type_par, const char *name_arg, enum ha_key_alg alg_par, bool generated_arg, List< key_part_spec > &cols) | |
| ~Key () | |
Public Attributes | |
| List< key_part_spec > | columns |
| const char * | name |
| bool | generated |
Friends | |
| bool | foreign_key_prefix (Key *a, Key *b) |
|
|
00267 { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY};
|
|
||||||||||||||||||||||||
|
00276 :type(type_par), algorithm(alg_par), columns(cols), name(name_arg), 00277 generated(generated_arg) 00278 {}
|
|
|
00279 {}
|
|
||||||||||||
|
00106 {
00107 /* Ensure that 'a' is the generated key */
00108 if (a->generated)
00109 {
00110 if (b->generated && a->columns.elements > b->columns.elements)
00111 swap_variables(Key*, a, b); // Put shorter key in 'a'
00112 }
00113 else
00114 {
00115 if (!b->generated)
00116 return TRUE; // No foreign key
00117 swap_variables(Key*, a, b); // Put generated key in 'a'
00118 }
00119
00120 /* Test if 'a' is a prefix of 'b' */
00121 if (a->columns.elements > b->columns.elements)
00122 return TRUE; // Can't be prefix
00123
00124 List_iterator<key_part_spec> col_it1(a->columns);
00125 List_iterator<key_part_spec> col_it2(b->columns);
00126 const key_part_spec *col1, *col2;
00127
00128 #ifdef ENABLE_WHEN_INNODB_CAN_HANDLE_SWAPED_FOREIGN_KEY_COLUMNS
00129 while ((col1= col_it1++))
00130 {
00131 bool found= 0;
00132 col_it2.rewind();
00133 while ((col2= col_it2++))
00134 {
00135 if (*col1 == *col2)
00136 {
00137 found= TRUE;
00138 break;
00139 }
00140 }
00141 if (!found)
00142 return TRUE; // Error
00143 }
00144 return FALSE; // Is prefix
00145 #else
00146 while ((col1= col_it1++))
00147 {
00148 col2= col_it2++;
00149 if (!(*col1 == *col2))
00150 return TRUE;
00151 }
00152 return FALSE; // Is prefix
00153 #endif
00154 }
|
|
|
|
|
|
|
|
|
|
1.3.9.1