mirror of
https://github.com/MariaDB/server.git
synced 2026-04-26 18:25:30 +02:00
Fix bug #3443, better foreign key error messsages.
innobase/dict/dict0dict.c: Add 'add_newline' parameter to dict_print_info_on_foreign_key_in_create_format. innobase/include/dict0dict.h: Add 'add_newline' parameter to dict_print_info_on_foreign_key_in_create_format. innobase/include/os0file.h: Add os_file_read_string. innobase/include/trx0trx.h: Add trx_set_detailed_error and trx_set_detailed_error_from_file functions and a detailed_error field to trx_struct. innobase/include/ut0mem.h: Add ut_strlcpy. innobase/os/os0file.c: Add os_file_read_string. innobase/row/row0ins.c: Add row_ins_set_detailed function and call it when needed. Adapt to changes in dict_print_info_on_foreign_key_in_create_format. innobase/trx/trx0trx.c: Add trx_set_detailed_error and trx_set_detailed_error_from_file. Clear trx->detailed_error in trx_create. innobase/ut/ut0mem.c: Add ut_strlcpy. mysql-test/r/innodb.result: Add new tests, adapt existing ones whose output was changed. mysql-test/t/innodb.test: Add new tests, adapt existing ones whose output was changed. sql/ha_innodb.cc: Add get_error_message. Clear trx->detailed_error in start_stmt and external_lock. sql/ha_innodb.h: Add get_error_message. sql/handler.cc: Add special case code in print_error for HA_ERR_ROW_IS_REFERENCED and HA_ERR_NO_REFERENCED_ROW. Change SETMSG to point to new error messages. sql/share/errmsg.txt: Add ER_ROW_IS_REFERENCED_2 and ER_NO_REFERENCED_ROW_2.
This commit is contained in:
parent
abda6dc69f
commit
e4b0b0d00c
15 changed files with 274 additions and 25 deletions
|
|
@ -375,9 +375,10 @@ CREATE TABLE. */
|
|||
void
|
||||
dict_print_info_on_foreign_key_in_create_format(
|
||||
/*============================================*/
|
||||
FILE* file, /* in: file where to print */
|
||||
trx_t* trx, /* in: transaction */
|
||||
dict_foreign_t* foreign);/* in: foreign key constraint */
|
||||
FILE* file, /* in: file where to print */
|
||||
trx_t* trx, /* in: transaction */
|
||||
dict_foreign_t* foreign, /* in: foreign key constraint */
|
||||
ibool add_newline); /* in: whether to add a newline */
|
||||
/************************************************************************
|
||||
Displays the names of the index and the table. */
|
||||
void
|
||||
|
|
|
|||
|
|
@ -432,6 +432,17 @@ os_file_read(
|
|||
offset */
|
||||
ulint n); /* in: number of bytes to read */
|
||||
/***********************************************************************
|
||||
Rewind file to its start, read at most size - 1 bytes from it to str, and
|
||||
NUL-terminate str. All errors are silently ignored. This function is
|
||||
mostly meant to be used with temporary files. */
|
||||
|
||||
void
|
||||
os_file_read_string(
|
||||
/*================*/
|
||||
FILE* file, /* in: file to read from */
|
||||
char* str, /* in: buffer where to read */
|
||||
ulint size); /* in: size of buffer */
|
||||
/***********************************************************************
|
||||
Requests a synchronous positioned read operation. This function does not do
|
||||
any error handling. In case of error it returns FALSE. */
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,22 @@ void
|
|||
trx_search_latch_release_if_reserved(
|
||||
/*=================================*/
|
||||
trx_t* trx); /* in: transaction */
|
||||
/**********************************************************************
|
||||
Set detailed error message for the transaction. */
|
||||
void
|
||||
trx_set_detailed_error(
|
||||
/*===================*/
|
||||
trx_t* trx, /* in: transaction struct */
|
||||
char* msg); /* in: detailed error message */
|
||||
/*****************************************************************
|
||||
Set detailed error message for the transaction from a file. Note that the
|
||||
file is rewinded before reading from it. */
|
||||
|
||||
void
|
||||
trx_set_detailed_error_from_file(
|
||||
/*=============================*/
|
||||
trx_t* trx, /* in: transaction struct */
|
||||
FILE* file); /* in: file to read message from */
|
||||
/********************************************************************
|
||||
Retrieves the error_info field from a trx. */
|
||||
|
||||
|
|
@ -649,6 +665,9 @@ struct trx_struct{
|
|||
trx_undo_arr_t* undo_no_arr; /* array of undo numbers of undo log
|
||||
records which are currently processed
|
||||
by a rollback operation */
|
||||
/*------------------------------*/
|
||||
char detailed_error[256]; /* detailed error message for last
|
||||
error, or empty. */
|
||||
};
|
||||
|
||||
#define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
|
||||
|
|
|
|||
|
|
@ -118,6 +118,18 @@ UNIV_INLINE
|
|||
int
|
||||
ut_strcmp(const void* str1, const void* str2);
|
||||
|
||||
/**************************************************************************
|
||||
Copies up to size - 1 characters from the NUL-terminated string src to
|
||||
dst, NUL-terminating the result. Returns strlen(src), so truncation
|
||||
occurred if the return value >= size. */
|
||||
ulint
|
||||
ut_strlcpy(
|
||||
/*=======*/
|
||||
/* out: strlen(src) */
|
||||
char* dst, /* in: destination buffer */
|
||||
const char* src, /* in: source buffer */
|
||||
ulint size); /* in: size of destination buffer */
|
||||
|
||||
/**************************************************************************
|
||||
Compute strlen(ut_strcpyq(str, q)). */
|
||||
UNIV_INLINE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue