Commit 1d3d9ec1 authored by unknown's avatar unknown

Fixed some warning and error messages so that they use

sql_print_warning() and sql_print_error() instead of fprintf to stderr.
Above functions are tuned for different platforms so that the behavior
is consistent around platforms. Using fprintf() different behavior can
be expected at least on Windows and Unix.

parent 98da6d5f
...@@ -948,9 +948,7 @@ innobase_query_caching_of_table_permitted( ...@@ -948,9 +948,7 @@ innobase_query_caching_of_table_permitted(
trx = check_trx_exists(thd); trx = check_trx_exists(thd);
if (trx->has_search_latch) { if (trx->has_search_latch) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("The calling thread is holding the adaptive search, latch though calling innobase_query_caching_of_table_permitted.");
" InnoDB: Error: the calling thread is holding the adaptive search\n"
"InnoDB: latch though calling innobase_query_caching_of_table_permitted\n");
} }
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
...@@ -1266,9 +1264,7 @@ innobase_init(void) ...@@ -1266,9 +1264,7 @@ innobase_init(void)
&srv_log_group_home_dirs); &srv_log_group_home_dirs);
if (ret == FALSE || innobase_mirrored_log_groups != 1) { if (ret == FALSE || innobase_mirrored_log_groups != 1) {
fprintf(stderr, sql_print_error("syntax error in innodb_log_group_home_dir, or a wrong number of mirrored log groups");
"InnoDB: syntax error in innodb_log_group_home_dir\n"
"InnoDB: or a wrong number of mirrored log groups\n");
my_free(internal_innobase_data_file_path, my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR)); MYF(MY_ALLOW_ZERO_PTR));
...@@ -1562,11 +1558,8 @@ innobase_commit( ...@@ -1562,11 +1558,8 @@ innobase_commit(
if (trx->active_trans == 0 if (trx->active_trans == 0
&& trx->conc_state != TRX_NOT_STARTED) { && trx->conc_state != TRX_NOT_STARTED) {
fprintf(stderr, sql_print_error("trx->active_trans == 0, but trx->conc_state != TRX_NOT_STARTED");
"InnoDB: Error: trx->active_trans == 0\n"
"InnoDB: but trx->conc_state != TRX_NOT_STARTED\n");
} }
if (all if (all
|| (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) { || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
...@@ -1813,21 +1806,7 @@ try_again: ...@@ -1813,21 +1806,7 @@ try_again:
if (ret != 0) { if (ret != 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("MySQL synchronous replication was not able to send the binlog to the slave within the timeout %lu. We assume that the slave has become inaccessible, and switch off synchronous replication until the communication to the slave works again. MySQL synchronous replication has sent binlog to the slave up to file %s, position %lu. This transaction needs it to be sent up to file %s, position %lu.", thd->variables.sync_replication_timeout, innobase_repl_file_name, (ulong)innobase_repl_pos, trx->repl_wait_binlog_name, (ulong)trx->repl_wait_binlog_pos);
" InnoDB: Error: MySQL synchronous replication\n"
"InnoDB: was not able to send the binlog to the slave within the\n"
"InnoDB: timeout %lu. We assume that the slave has become inaccessible,\n"
"InnoDB: and switch off synchronous replication until the communication.\n"
"InnoDB: to the slave works again.\n",
thd->variables.sync_replication_timeout);
fprintf(stderr,
"InnoDB: MySQL synchronous replication has sent binlog\n"
"InnoDB: to the slave up to file %s, position %lu\n", innobase_repl_file_name,
(ulong)innobase_repl_pos);
fprintf(stderr,
"InnoDB: This transaction needs it to be sent up to\n"
"InnoDB: file %s, position %lu\n", trx->repl_wait_binlog_name,
(ulong)trx->repl_wait_binlog_pos);
innobase_repl_state = 0; innobase_repl_state = 0;
...@@ -1878,9 +1857,7 @@ innobase_repl_report_sent_binlog( ...@@ -1878,9 +1857,7 @@ innobase_repl_report_sent_binlog(
if (innobase_repl_state == 0) { if (innobase_repl_state == 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_warning("Switching MySQL synchronous replication on again at binlog file %s, position %lu", log_file_name, (ulong) end_offset);
" InnoDB: Switching MySQL synchronous replication on again at\n"
"InnoDB: binlog file %s, position %lu\n", log_file_name, (ulong)end_offset);
innobase_repl_state = 1; innobase_repl_state = 1;
} }
...@@ -1897,14 +1874,7 @@ innobase_repl_report_sent_binlog( ...@@ -1897,14 +1874,7 @@ innobase_repl_report_sent_binlog(
|| (cmp == 0 && end_offset < innobase_repl_pos)) { || (cmp == 0 && end_offset < innobase_repl_pos)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("MySQL synchronous replication has sent binlog to the slave up to file %s, position %lu, but now MySQL reports that it sent the binlog only up to file %s, position %lu", innobase_repl_file_name, (ulong)innobase_repl_pos, log_file_name, (ulong) end_offset);
" InnoDB: Error: MySQL synchronous replication has sent binlog\n"
"InnoDB: to the slave up to file %s, position %lu\n", innobase_repl_file_name,
(ulong)innobase_repl_pos);
fprintf(stderr,
"InnoDB: but now MySQL reports that it sent the binlog only up to\n"
"InnoDB: file %s, position %lu\n", log_file_name, (ulong)end_offset);
} }
} }
...@@ -2149,9 +2119,7 @@ innobase_close_connection( ...@@ -2149,9 +2119,7 @@ innobase_close_connection(
if (trx->active_trans == 0 if (trx->active_trans == 0
&& trx->conc_state != TRX_NOT_STARTED) { && trx->conc_state != TRX_NOT_STARTED) {
fprintf(stderr, sql_print_error("trx->active_trans == 0, but trx->conc_state != TRX_NOT_STARTED");
"InnoDB: Error: trx->active_trans == 0\n"
"InnoDB: but trx->conc_state != TRX_NOT_STARTED\n");
} }
...@@ -2363,9 +2331,7 @@ ha_innobase::open( ...@@ -2363,9 +2331,7 @@ ha_innobase::open(
if (!row_table_got_default_clust_index(ib_table)) { if (!row_table_got_default_clust_index(ib_table)) {
if (primary_key >= MAX_KEY) { if (primary_key >= MAX_KEY) {
fprintf(stderr, sql_print_error("Table %s has a primary key in InnoDB data dictionary, but not in MySQL!", name);
"InnoDB: Error: table %s has a primary key in InnoDB\n"
"InnoDB: data dictionary, but not in MySQL!\n", name);
} }
((row_prebuilt_t*)innobase_prebuilt) ((row_prebuilt_t*)innobase_prebuilt)
...@@ -2379,16 +2345,7 @@ ha_innobase::open( ...@@ -2379,16 +2345,7 @@ ha_innobase::open(
ref_length = table->key_info[primary_key].key_length; ref_length = table->key_info[primary_key].key_length;
} else { } else {
if (primary_key != MAX_KEY) { if (primary_key != MAX_KEY) {
fprintf(stderr, sql_print_error("Table %s has no primary key in InnoDB data dictionary, but has one in MySQL! If you created the table with a MySQL version < 3.23.54 and did not define a primary key, but defined a unique key with all non-NULL columns, then MySQL internally treats that key as the primary key. You can fix this error by dump + DROP + CREATE + reimport of the table.", name);
"InnoDB: Error: table %s has no primary key in InnoDB\n"
"InnoDB: data dictionary, but has one in MySQL!\n"
"InnoDB: If you created the table with a MySQL\n"
"InnoDB: version < 3.23.54 and did not define a primary\n"
"InnoDB: key, but defined a unique key with all non-NULL\n"
"InnoDB: columns, then MySQL internally treats that key\n"
"InnoDB: as the primary key. You can fix this error by\n"
"InnoDB: dump + DROP + CREATE + reimport of the table.\n",
name);
} }
((row_prebuilt_t*)innobase_prebuilt) ((row_prebuilt_t*)innobase_prebuilt)
...@@ -2405,10 +2362,7 @@ ha_innobase::open( ...@@ -2405,10 +2362,7 @@ ha_innobase::open(
and it will never be updated anyway. */ and it will never be updated anyway. */
if (key_used_on_scan != MAX_KEY) { if (key_used_on_scan != MAX_KEY) {
fprintf(stderr, sql_print_warning("Table %s key_used_on_scan is %lu even though there is no primary key inside InnoDB.", name, (ulong) key_used_on_scan);
"InnoDB: Warning: table %s key_used_on_scan is %lu even though there is no\n"
"InnoDB: primary key inside InnoDB.\n",
name, (ulong)key_used_on_scan);
} }
} }
...@@ -2563,9 +2517,7 @@ innobase_mysql_cmp( ...@@ -2563,9 +2517,7 @@ innobase_mysql_cmp(
charset = get_charset(charset_number, MYF(MY_WME)); charset = get_charset(charset_number, MYF(MY_WME));
if (charset == NULL) { if (charset == NULL) {
fprintf(stderr, sql_print_error("InnoDB needs charset %lu for doing a comparison, but MySQL cannot find that charset.", (ulong) charset_number);
"InnoDB: fatal error: InnoDB needs charset %lu for doing a comparison,\n"
"InnoDB: but MySQL cannot find that charset.\n", (ulong)charset_number);
ut_a(0); ut_a(0);
} }
} }
...@@ -3131,11 +3083,8 @@ ha_innobase::write_row( ...@@ -3131,11 +3083,8 @@ ha_innobase::write_row(
if (prebuilt->trx != if (prebuilt->trx !=
(trx_t*) current_thd->ha_data[innobase_hton.slot]) { (trx_t*) current_thd->ha_data[innobase_hton.slot]) {
fprintf(stderr, sql_print_error("The transaction object for the table handle is at %p, but for the current thread it is at %p", prebuilt->trx, (trx_t*) current_thd->ha_data[innobase_hton.slot]);
"InnoDB: Error: the transaction object for the table handle is at\n"
"InnoDB: %p, but for the current thread it is at %p\n",
prebuilt->trx,
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr); fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200); ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200);
fputs("\n" fputs("\n"
...@@ -3622,9 +3571,7 @@ ha_innobase::unlock_row(void) ...@@ -3622,9 +3571,7 @@ ha_innobase::unlock_row(void)
if (last_query_id != user_thd->query_id) { if (last_query_id != user_thd->query_id) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("last_query_id is %lu != user_thd_query_id is %lu", (ulong) last_query_id, (ulong) user_thd->query_id);
" InnoDB: Error: last_query_id is %lu != user_thd_query_id is %lu\n",
(ulong)last_query_id, (ulong)user_thd->query_id);
mem_analyze_corruption((byte *) prebuilt->trx); mem_analyze_corruption((byte *) prebuilt->trx);
ut_error; ut_error;
} }
...@@ -4284,9 +4231,8 @@ ha_innobase::position( ...@@ -4284,9 +4231,8 @@ ha_innobase::position(
table. */ table. */
if (len != ref_length) { if (len != ref_length) {
fprintf(stderr, sql_print_error("Stored ref len is %lu, but table ref len is %lu",
"InnoDB: Error: stored ref len is %lu, but table ref len is %lu\n", (ulong) len, (ulong) ref_length);
(ulong)len, (ulong)ref_length);
} }
} }
...@@ -4491,11 +4437,8 @@ create_index( ...@@ -4491,11 +4437,8 @@ create_index(
|| col_type == DATA_FLOAT || col_type == DATA_FLOAT
|| col_type == DATA_DOUBLE || col_type == DATA_DOUBLE
|| col_type == DATA_DECIMAL) { || col_type == DATA_DECIMAL) {
fprintf(stderr, sql_print_error("MySQL is trying to create a column prefix index field, on an inappropriate data type. Table name %s, column name %s.", table_name, key_part->field->field_name);
"InnoDB: error: MySQL is trying to create a column prefix index field\n"
"InnoDB: on an inappropriate data type. Table name %s, column name %s.\n",
table_name, key_part->field->field_name);
prefix_len = 0; prefix_len = 0;
} }
} else { } else {
...@@ -5378,12 +5321,7 @@ ha_innobase::info( ...@@ -5378,12 +5321,7 @@ ha_innobase::info(
for (i = 0; i < table->s->keys; i++) { for (i = 0; i < table->s->keys; i++) {
if (index == NULL) { if (index == NULL) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("Table %s contains less indexes inside InnoDB than are defined in the MySQL .frm file. Have you mixed up .frm files from different installations? See section 15.1 at http://www.innodb.com/ibman.html", ib_table->name);
" InnoDB: Error: table %s contains less indexes inside InnoDB\n"
"InnoDB: than are defined in the MySQL .frm file. Have you mixed up\n"
"InnoDB: .frm files from different installations? See section\n"
"InnoDB: 15.1 at http://www.innodb.com/ibman.html\n",
ib_table->name);
break; break;
} }
...@@ -5391,15 +5329,7 @@ ha_innobase::info( ...@@ -5391,15 +5329,7 @@ ha_innobase::info(
if (j + 1 > index->n_uniq) { if (j + 1 > index->n_uniq) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("Index %s of %s has %lu columns unique inside InnoDB, but MySQL is asking statistics for %lu columns. Have you mixed up .frm files from different installations? See section 15.1 at http://www.innodb.com/ibman.html", index->name, ib_table->name, (unsigned long) index->n_uniq, j + 1);
" InnoDB: Error: index %s of %s has %lu columns unique inside InnoDB\n"
"InnoDB: but MySQL is asking statistics for %lu columns. Have you mixed up\n"
"InnoDB: .frm files from different installations? See section\n"
"InnoDB: 15.1 at http://www.innodb.com/ibman.html\n",
index->name,
ib_table->name,
(unsigned long) index->n_uniq,
j + 1);
break; break;
} }
...@@ -5947,9 +5877,7 @@ ha_innobase::start_stmt( ...@@ -5947,9 +5877,7 @@ ha_innobase::start_stmt(
if (prebuilt->stored_select_lock_type != LOCK_S if (prebuilt->stored_select_lock_type != LOCK_S
&& prebuilt->stored_select_lock_type != LOCK_X) { && prebuilt->stored_select_lock_type != LOCK_X) {
fprintf(stderr, sql_print_error("stored_select_lock_type is %lu inside ::start_stmt()!", prebuilt->stored_select_lock_type);
"InnoDB: Error: stored_select_lock_type is %lu inside ::start_stmt()!\n",
prebuilt->stored_select_lock_type);
/* Set the value to LOCK_X: this is just fault /* Set the value to LOCK_X: this is just fault
tolerance, we do not know what the correct value tolerance, we do not know what the correct value
...@@ -6725,9 +6653,7 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -6725,9 +6653,7 @@ ha_innobase::innobase_read_and_init_auto_inc(
error = 0; error = 0;
} else { } else {
/* This should not happen in a consistent read */ /* This should not happen in a consistent read */
fprintf(stderr, sql_print_error("Consistent read of auto-inc column returned %lu", (ulong) error);
"InnoDB: Error: consistent read of auto-inc column returned %lu\n",
(ulong)error);
auto_inc = -1; auto_inc = -1;
goto func_exit; goto func_exit;
...@@ -6784,9 +6710,8 @@ ha_innobase::get_auto_increment() ...@@ -6784,9 +6710,8 @@ ha_innobase::get_auto_increment()
initialized. */ initialized. */
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, sql_print_error("Error %lu in ::get_auto_increment()",
" InnoDB: Error: error %lu in ::get_auto_increment()\n", (ulong) error);
(ulong)error);
return(~(ulonglong) 0); return(~(ulonglong) 0);
} }
...@@ -7053,9 +6978,7 @@ innobase_xa_prepare( ...@@ -7053,9 +6978,7 @@ innobase_xa_prepare(
if (trx->active_trans == 0 && trx->conc_state != TRX_NOT_STARTED) { if (trx->active_trans == 0 && trx->conc_state != TRX_NOT_STARTED) {
fprintf(stderr, sql_print_error("trx->active_trans == 0, but trx->conc_state != TRX_NOT_STARTED");
"InnoDB: Error: trx->active_trans == 0\n"
"InnoDB: but trx->conc_state != TRX_NOT_STARTED\n");
} }
if (all if (all
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment