diff options
author | unknown <monty@mishka.local> | 2004-04-26 15:53:31 +0300 |
---|---|---|
committer | unknown <monty@mishka.local> | 2004-04-26 15:53:31 +0300 |
commit | 1065f2bbd66ac4b1161f5c188171a54cbad5b422 (patch) | |
tree | 25e3315af05fa92d20d2ad1d812882957c400337 /innobase/row/row0ins.c | |
parent | 0ba6cb48d84f1ff951d09871a96be6cdef3f2c3c (diff) | |
parent | 6366a9090c7fc24f0e13b5b9d73d6777dcda9d9e (diff) | |
download | mariadb-git-1065f2bbd66ac4b1161f5c188171a54cbad5b422.tar.gz |
Merge with 4.0
innobase/dict/dict0boot.c:
Auto merged
innobase/dict/dict0load.c:
Auto merged
innobase/dict/dict0mem.c:
Auto merged
innobase/fut/fut0lst.c:
Auto merged
innobase/include/buf0lru.h:
Auto merged
innobase/include/dict0mem.h:
Auto merged
innobase/include/fsp0fsp.h:
Auto merged
innobase/include/ha0ha.h:
Auto merged
innobase/include/ibuf0ibuf.h:
Auto merged
innobase/include/lock0lock.h:
Auto merged
innobase/include/log0log.h:
Auto merged
innobase/include/mem0pool.h:
Auto merged
innobase/include/mtr0mtr.h:
Auto merged
innobase/include/os0file.h:
Auto merged
innobase/include/rem0rec.h:
Auto merged
innobase/include/rem0rec.ic:
Auto merged
innobase/include/srv0srv.h:
Auto merged
innobase/include/sync0sync.h:
Auto merged
innobase/include/trx0sys.h:
Auto merged
innobase/include/ut0byte.h:
Auto merged
innobase/include/ut0ut.h:
Auto merged
innobase/mem/mem0pool.c:
Auto merged
innobase/mtr/mtr0mtr.c:
Auto merged
innobase/os/os0proc.c:
Auto merged
innobase/pars/lexyy.c:
Auto merged
innobase/pars/pars0opt.c:
Auto merged
innobase/row/row0ins.c:
Auto merged
innobase/row/row0purge.c:
Auto merged
innobase/row/row0uins.c:
Auto merged
innobase/row/row0umod.c:
Auto merged
innobase/row/row0undo.c:
Auto merged
innobase/row/row0upd.c:
Auto merged
innobase/trx/trx0purge.c:
Auto merged
innobase/trx/trx0roll.c:
Auto merged
innobase/trx/trx0sys.c:
Auto merged
innobase/trx/trx0undo.c:
Auto merged
innobase/ut/ut0byte.c:
Auto merged
pstack/bucomm.h:
Auto merged
pstack/budbg.h:
Auto merged
sql/item_sum.h:
Auto merged
sql/slave.cc:
Auto merged
sql/sql_db.cc:
Auto merged
support-files/mysql.spec.sh:
Auto merged
tests/insert_test.c:
Auto merged
mysql-test/t/func_group.test:
Merge with 4.0
Put 4.1 tests lasts
sql/ha_innodb.cc:
Merge with 4.0
Added checking of results from my_malloc()
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'innobase/row/row0ins.c')
-rw-r--r-- | innobase/row/row0ins.c | 202 |
1 files changed, 83 insertions, 119 deletions
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index fc1f7a19d53..a3f883b49c6 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -528,34 +528,37 @@ row_ins_foreign_report_err( dtuple_t* entry) /* in: index entry in the parent table */ { - char* buf = dict_foreign_err_buf; + FILE* ef = dict_foreign_err_file; mutex_enter(&dict_foreign_err_mutex); - ut_sprintf_timestamp(buf); - sprintf(buf + strlen(buf), " Transaction:\n"); - trx_print(buf + strlen(buf), thr_get_trx(thr)); - - sprintf(buf + strlen(buf), -"Foreign key constraint fails for table %.500s:\n", - foreign->foreign_table_name); - dict_print_info_on_foreign_key_in_create_format( - foreign, buf + strlen(buf)); - sprintf(buf + strlen(buf), "\n%s", errstr); - sprintf(buf + strlen(buf), -" in parent table, in index %.500s tuple:\n", - foreign->referenced_index->name); + rewind(ef); + ut_print_timestamp(ef); + fputs(" Transaction:\n", ef); + trx_print(ef, thr_get_trx(thr)); + + fputs("Foreign key constraint fails for table ", ef); + ut_print_name(ef, foreign->foreign_table_name); + fputs(":\n", ef); + dict_print_info_on_foreign_key_in_create_format(ef, foreign); + putc('\n', ef); + fputs(errstr, ef); + fputs(" in parent table, in index ", ef); + ut_print_name(ef, foreign->referenced_index->name); if (entry) { - dtuple_sprintf(buf + strlen(buf), 1000, entry); + fputs(" tuple:\n", ef); + dtuple_print(ef, entry); } - sprintf(buf + strlen(buf), -"\nBut in child table %.500s, in index %.500s, there is a record:\n", - foreign->foreign_table_name, foreign->foreign_index->name); + fputs("\nBut in child table ", ef); + ut_print_name(ef, foreign->foreign_table_name); + fputs(", in index ", ef); + ut_print_name(ef, foreign->foreign_index->name); if (rec) { - rec_sprintf(buf + strlen(buf), 1000, rec); + fputs(", there is a record:\n", ef); + rec_print(ef, rec); + } else { + fputs(", the record is not available\n", ef); } - sprintf(buf + strlen(buf), "\n"); - - ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); + putc('\n', ef); mutex_exit(&dict_foreign_err_mutex); } @@ -568,8 +571,7 @@ static void row_ins_foreign_report_add_err( /*===========================*/ - que_thr_t* thr, /* in: query thread whose run_node - is an insert node */ + trx_t* trx, /* in: transaction */ dict_foreign_t* foreign, /* in: foreign key constraint */ rec_t* rec, /* in: a record in the parent table: it does not match entry because we @@ -577,28 +579,28 @@ row_ins_foreign_report_add_err( dtuple_t* entry) /* in: index entry to insert in the child table */ { - char* buf = dict_foreign_err_buf; + FILE* ef = dict_foreign_err_file; mutex_enter(&dict_foreign_err_mutex); - ut_sprintf_timestamp(buf); - sprintf(buf + strlen(buf), " Transaction:\n"); - trx_print(buf + strlen(buf), thr_get_trx(thr)); - sprintf(buf + strlen(buf), -"Foreign key constraint fails for table %.500s:\n", - foreign->foreign_table_name); - dict_print_info_on_foreign_key_in_create_format( - foreign, buf + strlen(buf)); - sprintf(buf + strlen(buf), -"\nTrying to add in child table, in index %.500s tuple:\n", - foreign->foreign_index->name); + rewind(ef); + ut_print_timestamp(ef); + fputs(" Transaction:\n", ef); + trx_print(ef, trx); + fputs("Foreign key constraint fails for table ", ef); + ut_print_name(ef, foreign->foreign_table_name); + fputs(":\n", ef); + dict_print_info_on_foreign_key_in_create_format(ef, foreign); + fputs("\nTrying to add in child table, in index ", ef); + ut_print_name(ef, foreign->foreign_index->name); if (entry) { - dtuple_sprintf(buf + strlen(buf), 1000, entry); + fputs(" tuple:\n", ef); + dtuple_print(ef, entry); } - sprintf(buf + strlen(buf), -"\nBut in parent table %.500s, in index %.500s,\n" -"the closest match we can find is record:\n", - foreign->referenced_table_name, - foreign->referenced_index->name); + fputs("\nBut in parent table ", ef); + ut_print_name(ef, foreign->referenced_table_name); + fputs(", in index ", ef); + ut_print_name(ef, foreign->referenced_index->name); + fputs(",\nthe closest match we can find is record:\n", ef); if (rec && page_rec_is_supremum(rec)) { /* If the cursor ended on a supremum record, it is better to report the previous record in the error message, so that @@ -607,11 +609,9 @@ row_ins_foreign_report_add_err( } if (rec) { - rec_sprintf(buf + strlen(buf), 1000, rec); + rec_print(ef, rec); } - sprintf(buf + strlen(buf), "\n"); - - ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); + putc('\n', ef); mutex_exit(&dict_foreign_err_mutex); } @@ -653,7 +653,6 @@ row_ins_foreign_check_on_constraint( ulint i; char* ptr; char table_name_buf[1000]; - char err_buf[1000]; ut_a(thr && foreign && pcur && mtr); @@ -661,15 +660,10 @@ row_ins_foreign_check_on_constraint( the MySQL query cache for table */ ut_a(ut_strlen(table->name) < 998); - - ut_memcpy(table_name_buf, table->name, ut_strlen(table->name) + 1); - - ptr = table_name_buf; - - while (*ptr != '/') { - ptr++; - } + strcpy(table_name_buf, table->name); + ptr = strchr(table_name_buf, '/'); + ut_a(ptr); *ptr = '\0'; /* We call a function in ha_innodb.cc */ @@ -797,20 +791,20 @@ row_ins_foreign_check_on_constraint( || btr_pcur_get_low_match(cascade->pcur) < dict_index_get_n_unique(clust_index)) { - fprintf(stderr, + fputs( "InnoDB: error in cascade of a foreign key op\n" - "InnoDB: index %s table %s\n", index->name, - index->table->name); - - rec_sprintf(err_buf, 900, rec); - fprintf(stderr, "InnoDB: record %s\n", err_buf); - - rec_sprintf(err_buf, 900, clust_rec); - fprintf(stderr, "InnoDB: clustered record %s\n", - err_buf); - fprintf(stderr, - "InnoDB: Make a detailed bug report and send it\n"); - fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n"); + "InnoDB: ", stderr); + dict_index_name_print(stderr, index); + + fputs("\n" + "InnoDB: record ", stderr); + rec_print(stderr, rec); + fputs("\n" + "InnoDB: clustered record ", stderr); + rec_print(stderr, clust_rec); + fputs("\n" + "InnoDB: Make a detailed bug report and send it\n" + "InnoDB: to mysql@lists.mysql.com\n", stderr); err = DB_SUCCESS; @@ -840,24 +834,6 @@ row_ins_foreign_check_on_constraint( /* This can happen if there is a circular reference of rows such that cascading delete comes to delete a row already in the process of being delete marked */ -/* - fprintf(stderr, - "InnoDB: error 2 in cascade of a foreign key op\n" - "InnoDB: index %s table %s\n", index->name, - index->table->name); - - rec_sprintf(err_buf, 900, rec); - fprintf(stderr, "InnoDB: record %s\n", err_buf); - - rec_sprintf(err_buf, 900, clust_rec); - fprintf(stderr, "InnoDB: clustered record %s\n", err_buf); - - fprintf(stderr, - "InnoDB: Make a detailed bug report and send it\n"); - fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n"); - - ut_error; -*/ err = DB_SUCCESS; goto nonstandard_exit_func; @@ -1028,7 +1004,6 @@ row_ins_check_foreign_constraint( int cmp; ulint err; ulint i; - char* buf = dict_foreign_err_buf; mtr_t mtr; run_again: @@ -1091,23 +1066,24 @@ run_again: if (check_table == NULL) { if (check_ref) { + FILE* ef = dict_foreign_err_file; mutex_enter(&dict_foreign_err_mutex); - ut_sprintf_timestamp(buf); - sprintf(buf + strlen(buf), " Transaction:\n"); - trx_print(buf + strlen(buf), thr_get_trx(thr)); - sprintf(buf + strlen(buf), -"Foreign key constraint fails for table %.500s:\n", - foreign->foreign_table_name); - dict_print_info_on_foreign_key_in_create_format( - foreign, buf + strlen(buf)); - sprintf(buf + strlen(buf), -"\nTrying to add to index %.500s tuple:\n", foreign->foreign_index->name); - dtuple_sprintf(buf + strlen(buf), 1000, entry); - sprintf(buf + strlen(buf), -"\nBut the parent table %.500s does not currently exist!\n", - foreign->referenced_table_name); - - ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); + rewind(ef); + ut_print_timestamp(ef); + fputs(" Transaction:\n", ef); + trx_print(ef, thr_get_trx(thr)); + fputs("Foreign key constraint fails for table ", ef); + ut_print_name(ef, foreign->foreign_table_name); + fputs(":\n", ef); + dict_print_info_on_foreign_key_in_create_format(ef, + foreign); + fputs("\nTrying to add to index ", ef); + ut_print_name(ef, foreign->foreign_index->name); + fputs(" tuple:\n", ef); + dtuple_print(ef, entry); + fputs("\nBut the parent table ", ef); + ut_print_name(ef, foreign->referenced_table_name); + fputs(" does not currently exist!\n", ef); mutex_exit(&dict_foreign_err_mutex); return(DB_NO_REFERENCED_ROW); @@ -1200,11 +1176,6 @@ run_again: break; } -/* printf( -"FOREIGN: Found matching record from %s %s\n", - check_index->table_name, check_index->name); - rec_print(rec); -*/ if (check_ref) { err = DB_SUCCESS; @@ -1244,7 +1215,7 @@ run_again: if (check_ref) { err = DB_NO_REFERENCED_ROW; row_ins_foreign_report_add_err( - thr, foreign, rec, entry); + thr_get_trx(thr), foreign, rec, entry); } else { err = DB_SUCCESS; } @@ -1260,7 +1231,7 @@ next_rec: if (check_ref) { rec = btr_pcur_get_rec(&pcur); row_ins_foreign_report_add_err( - thr, foreign, rec, entry); + thr_get_trx(thr), foreign, rec, entry); err = DB_NO_REFERENCED_ROW; } else { err = DB_SUCCESS; @@ -2176,15 +2147,8 @@ row_ins_step( error_handling: trx->error_state = err; - if (err == DB_SUCCESS) { - /* Ok: do nothing */ - - } else if (err == DB_LOCK_WAIT) { - - return(NULL); - } else { - /* SQL error detected */ - + if (err != DB_SUCCESS) { + /* err == DB_LOCK_WAIT or SQL error detected */ return(NULL); } |