mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
This patch is prerequisite for the 2nd milestone of WL#148 "Foreign keys"
storing and restoring information about foreign keys in the .FRM files and properly displaying it in SHOW CREATE TABLE output and I_S tables. The idea of this patch is to change type of Key_part_spec::field_name and Key::name to LEX_STRING in order to avoid extra strlen() calls during semantic analysis and statement execution, particularly, in code to be implemented on the 2nd milestone of WL#148. Note that since we are not using LEX_STRING everywhere yet (e.g. in Create_field and KEY) and we want to limit scope of our changes we have to do strlen() in places where we create Key and Key_part_spec instances from objects using plain (char*) for strings. These calls will go away during the process of further (char*) -> LEX_STRING refactoring. We have introduced these changes in 6.0 and backported them to 5.5 tree to make people aware of these changes as early as possible and to simplify merges with mysql-fk and mysql-6.1-fk trees. No test case is needed since this patch does not introduce any user visible changes.
This commit is contained in:
@ -145,9 +145,14 @@ typedef struct st_copy_info {
|
||||
|
||||
class Key_part_spec :public Sql_alloc {
|
||||
public:
|
||||
const char *field_name;
|
||||
LEX_STRING field_name;
|
||||
uint length;
|
||||
Key_part_spec(const char *name,uint len=0) :field_name(name), length(len) {}
|
||||
Key_part_spec(const LEX_STRING &name, uint len)
|
||||
: field_name(name), length(len)
|
||||
{}
|
||||
Key_part_spec(const char *name, const size_t name_len, uint len)
|
||||
: length(len)
|
||||
{ field_name.str= (char *)name; field_name.length= name_len; }
|
||||
bool operator==(const Key_part_spec& other) const;
|
||||
/**
|
||||
Construct a copy of this Key_part_spec. field_name is copied
|
||||
@ -200,15 +205,24 @@ public:
|
||||
enum Keytype type;
|
||||
KEY_CREATE_INFO key_create_info;
|
||||
List<Key_part_spec> columns;
|
||||
const char *name;
|
||||
LEX_STRING name;
|
||||
bool generated;
|
||||
|
||||
Key(enum Keytype type_par, const char *name_arg,
|
||||
Key(enum Keytype type_par, const LEX_STRING &name_arg,
|
||||
KEY_CREATE_INFO *key_info_arg,
|
||||
bool generated_arg, List<Key_part_spec> &cols)
|
||||
:type(type_par), key_create_info(*key_info_arg), columns(cols),
|
||||
name(name_arg), generated(generated_arg)
|
||||
{}
|
||||
Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
|
||||
KEY_CREATE_INFO *key_info_arg, bool generated_arg,
|
||||
List<Key_part_spec> &cols)
|
||||
:type(type_par), key_create_info(*key_info_arg), columns(cols),
|
||||
generated(generated_arg)
|
||||
{
|
||||
name.str= (char *)name_arg;
|
||||
name.length= name_len_arg;
|
||||
}
|
||||
Key(const Key &rhs, MEM_ROOT *mem_root);
|
||||
virtual ~Key() {}
|
||||
/* Equality comparison of keys (ignoring name) */
|
||||
@ -233,7 +247,7 @@ public:
|
||||
Table_ident *ref_table;
|
||||
List<Key_part_spec> ref_columns;
|
||||
uint delete_opt, update_opt, match_opt;
|
||||
Foreign_key(const char *name_arg, List<Key_part_spec> &cols,
|
||||
Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
|
||||
Table_ident *table, List<Key_part_spec> &ref_cols,
|
||||
uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg)
|
||||
:Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
|
||||
|
Reference in New Issue
Block a user