mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
Merge from mysql-5.1 to mysql-5.5.
This commit is contained in:
commit
86a4272a72
6 changed files with 61 additions and 1 deletions
|
@ -42,6 +42,7 @@ Created 1/8/1996 Heikki Tuuri
|
||||||
#include "trx0roll.h"
|
#include "trx0roll.h"
|
||||||
#include "usr0sess.h"
|
#include "usr0sess.h"
|
||||||
#include "ut0vec.h"
|
#include "ut0vec.h"
|
||||||
|
#include "ha_prototypes.h"
|
||||||
|
|
||||||
/*****************************************************************//**
|
/*****************************************************************//**
|
||||||
Based on a table object, this function builds the entry to be inserted
|
Based on a table object, this function builds the entry to be inserted
|
||||||
|
@ -1427,12 +1428,20 @@ dict_create_add_foreign_to_dictionary(
|
||||||
pars_info_t* info = pars_info_create();
|
pars_info_t* info = pars_info_create();
|
||||||
|
|
||||||
if (foreign->id == NULL) {
|
if (foreign->id == NULL) {
|
||||||
|
char* stripped_name;
|
||||||
/* Generate a new constraint id */
|
/* Generate a new constraint id */
|
||||||
ulint namelen = strlen(table->name);
|
ulint namelen = strlen(table->name);
|
||||||
char* id = mem_heap_alloc(foreign->heap, namelen + 20);
|
char* id = mem_heap_alloc(foreign->heap, namelen + 20);
|
||||||
/* no overflow if number < 1e13 */
|
/* no overflow if number < 1e13 */
|
||||||
sprintf(id, "%s_ibfk_%lu", table->name, (ulong) (*id_nr)++);
|
sprintf(id, "%s_ibfk_%lu", table->name, (ulong) (*id_nr)++);
|
||||||
foreign->id = id;
|
foreign->id = id;
|
||||||
|
|
||||||
|
stripped_name = strchr(foreign->id, '/') + 1;
|
||||||
|
if (innobase_check_identifier_length(stripped_name)) {
|
||||||
|
fprintf(stderr, "InnoDB: Generated foreign key "
|
||||||
|
"name (%s) is too long\n", foreign->id);
|
||||||
|
return(DB_IDENTIFIER_TOO_LONG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pars_info_add_str_literal(info, "id", foreign->id);
|
pars_info_add_str_literal(info, "id", foreign->id);
|
||||||
|
|
|
@ -4679,6 +4679,7 @@ dict_print_info_on_foreign_key_in_create_format(
|
||||||
dict_foreign_t* foreign, /*!< in: foreign key constraint */
|
dict_foreign_t* foreign, /*!< in: foreign key constraint */
|
||||||
ibool add_newline) /*!< in: whether to add a newline */
|
ibool add_newline) /*!< in: whether to add a newline */
|
||||||
{
|
{
|
||||||
|
char constraint_name[MAX_TABLE_NAME_LEN];
|
||||||
const char* stripped_id;
|
const char* stripped_id;
|
||||||
ulint i;
|
ulint i;
|
||||||
|
|
||||||
|
@ -4700,7 +4701,9 @@ dict_print_info_on_foreign_key_in_create_format(
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs(" CONSTRAINT ", file);
|
fputs(" CONSTRAINT ", file);
|
||||||
ut_print_name(file, trx, FALSE, stripped_id);
|
innobase_convert_from_id(&my_charset_filename, constraint_name,
|
||||||
|
stripped_id, MAX_TABLE_NAME_LEN);
|
||||||
|
ut_print_name(file, trx, FALSE, constraint_name);
|
||||||
fputs(" FOREIGN KEY (", file);
|
fputs(" FOREIGN KEY (", file);
|
||||||
|
|
||||||
for (i = 0;;) {
|
for (i = 0;;) {
|
||||||
|
|
|
@ -1075,6 +1075,9 @@ convert_error_code_to_mysql(
|
||||||
return(HA_ERR_UNDO_REC_TOO_BIG);
|
return(HA_ERR_UNDO_REC_TOO_BIG);
|
||||||
case DB_OUT_OF_MEMORY:
|
case DB_OUT_OF_MEMORY:
|
||||||
return(HA_ERR_OUT_OF_MEM);
|
return(HA_ERR_OUT_OF_MEM);
|
||||||
|
case DB_IDENTIFIER_TOO_LONG:
|
||||||
|
my_error(ER_TOO_LONG_IDENT, MYF(0));
|
||||||
|
return(HA_ERR_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1155,6 +1158,37 @@ innobase_convert_from_table_id(
|
||||||
strconvert(cs, from, &my_charset_filename, to, (uint) len, &errors);
|
strconvert(cs, from, &my_charset_filename, to, (uint) len, &errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
Check if the length of the identifier exceeds the maximum allowed.
|
||||||
|
The input to this function is an identifier in charset my_charset_filename.
|
||||||
|
return true when length of identifier is too long. */
|
||||||
|
extern "C" UNIV_INTERN
|
||||||
|
my_bool
|
||||||
|
innobase_check_identifier_length(
|
||||||
|
/*=============================*/
|
||||||
|
const char* id) /* in: identifier to check. it must belong
|
||||||
|
to charset my_charset_filename */
|
||||||
|
{
|
||||||
|
char tmp[MAX_TABLE_NAME_LEN + 10];
|
||||||
|
uint errors;
|
||||||
|
uint len;
|
||||||
|
int well_formed_error = 0;
|
||||||
|
CHARSET_INFO* cs1 = &my_charset_filename;
|
||||||
|
CHARSET_INFO* cs2 = thd_charset(current_thd);
|
||||||
|
|
||||||
|
len = strconvert(cs1, id, cs2, tmp, MAX_TABLE_NAME_LEN + 10, &errors);
|
||||||
|
|
||||||
|
uint res = cs2->cset->well_formed_len(cs2, tmp, tmp + len,
|
||||||
|
NAME_CHAR_LEN,
|
||||||
|
&well_formed_error);
|
||||||
|
|
||||||
|
if (well_formed_error || res != len) {
|
||||||
|
my_error(ER_TOO_LONG_IDENT, MYF(0), tmp);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************//**
|
/******************************************************************//**
|
||||||
Converts an identifier to UTF-8. */
|
Converts an identifier to UTF-8. */
|
||||||
extern "C" UNIV_INTERN
|
extern "C" UNIV_INTERN
|
||||||
|
|
|
@ -114,6 +114,7 @@ enum db_err {
|
||||||
DB_UNDO_RECORD_TOO_BIG, /* the undo log record is too big */
|
DB_UNDO_RECORD_TOO_BIG, /* the undo log record is too big */
|
||||||
DB_TABLE_IN_FK_CHECK, /* table is being used in foreign
|
DB_TABLE_IN_FK_CHECK, /* table is being used in foreign
|
||||||
key check */
|
key check */
|
||||||
|
DB_IDENTIFIER_TOO_LONG, /* Identifier name too long */
|
||||||
|
|
||||||
/* The following are partial failure codes */
|
/* The following are partial failure codes */
|
||||||
DB_FAIL = 1000,
|
DB_FAIL = 1000,
|
||||||
|
|
|
@ -296,4 +296,15 @@ ulint
|
||||||
innobase_get_lower_case_table_names(void);
|
innobase_get_lower_case_table_names(void);
|
||||||
/*=====================================*/
|
/*=====================================*/
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
Check if the length of the identifier exceeds the maximum allowed.
|
||||||
|
The input to this function is an identifier in charset my_charset_filename.
|
||||||
|
return true when length of identifier is too long. */
|
||||||
|
UNIV_INTERN
|
||||||
|
my_bool
|
||||||
|
innobase_check_identifier_length(
|
||||||
|
/*=============================*/
|
||||||
|
const char* id); /* in: identifier to check. it must belong
|
||||||
|
to charset my_charset_filename */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -728,6 +728,8 @@ ut_strerr(
|
||||||
return("End of index");
|
return("End of index");
|
||||||
case DB_TABLE_IN_FK_CHECK:
|
case DB_TABLE_IN_FK_CHECK:
|
||||||
return("Table is being used in foreign key check");
|
return("Table is being used in foreign key check");
|
||||||
|
case DB_IDENTIFIER_TOO_LONG:
|
||||||
|
return("Identifier name is too long");
|
||||||
/* do not add default: in order to produce a warning if new code
|
/* do not add default: in order to produce a warning if new code
|
||||||
is added to the enum but not added here */
|
is added to the enum but not added here */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue