From 08ebb9248f76820feacd3e56364d255be8d5b15e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Apr 2004 16:14:43 +0300 Subject: InnoDB: send diagnostic output to stderr or files instead of stdout or fixed-size memory buffers innobase/btr/btr0btr.c: Output to stderr; quote table and index names innobase/btr/btr0cur.c: Output to stderr; quote table and index names innobase/btr/btr0sea.c: Output to stderr innobase/buf/buf0buf.c: Output to stderr; quote table and index names innobase/buf/buf0flu.c: Output to stderr innobase/buf/buf0lru.c: Output to stderr innobase/buf/buf0rea.c: Output to stderr innobase/data/data0data.c: Remove dtuple_validate() unless #ifdef UNIV_DEBUG Remove unnecessary sprintf() calls Output to stderr innobase/data/data0type.c: Output to stderr innobase/dict/dict0boot.c: Remove dummy call to printf() innobase/dict/dict0crea.c: Output diagnostic information to stream, not to memory innobase/dict/dict0dict.c: Output diagnostics to a file, not to a memory buffer innobase/dict/dict0load.c: Output to stderr; quote table and index names innobase/eval/eval0eval.c: Output to stderr innobase/fil/fil0fil.c: Output to stderr innobase/fsp/fsp0fsp.c: Output to stderr Avoid sprintf() innobase/fut/fut0lst.c: Output to stderr innobase/ha/ha0ha.c: Output to stream, not to memory buffer innobase/ibuf/ibuf0ibuf.c: Output to stderr Avoid sprintf() innobase/include/buf0buf.h: Output to stream, not to memory buffer innobase/include/buf0buf.ic: Use %p for displaying pointers innobase/include/data0data.h: Remove dtuple_sprintf() innobase/include/dict0dict.h: Output to stream, not to memory buffer innobase/include/ha0ha.h: Output to stream, not to memory buffer innobase/include/ibuf0ibuf.h: Output to stream, not to memory buffer innobase/include/lock0lock.h: Output to stream, not to memory buffer innobase/include/log0log.h: Output to stream, not to memory buffer innobase/include/mtr0log.ic: Output to stderr Display pointers with %p innobase/include/os0file.h: Output to stream, not to memory buffer innobase/include/rem0rec.h: Remove rec_sprintf() innobase/include/rem0rec.ic: Output to stderr innobase/include/row0sel.ic: Output to stderr innobase/include/row0upd.ic: Quote table and index names innobase/include/srv0srv.h: Remove srv_sprintf_innodb_monitor() innobase/include/sync0arr.h: Output to stream, not to memory buffer innobase/include/sync0sync.h: Output to stream, not to memory buffer innobase/include/trx0sys.h: Output to stderr innobase/include/trx0trx.h: Output to stream, not to memory buffer innobase/include/ut0ut.h: Remove ut_sprintf_buf() Add ut_print_name(), ut_print_namel() and ut_copy_file() innobase/lock/lock0lock.c: Output to stream, not to memory buffer innobase/log/log0log.c: Output to stderr innobase/log/log0recv.c: Output to stderr innobase/mem/mem0dbg.c: Output to stderr innobase/mtr/mtr0log.c: Display pointers with %p innobase/mtr/mtr0mtr.c: Output to stderr innobase/os/os0file.c: Output to stream, not to memory buffer innobase/os/os0proc.c: Output to stderr innobase/os/os0thread.c: Output to stderr innobase/page/page0cur.c: Output to stderr innobase/page/page0page.c: Avoid sprintf() Output to stderr instead of stdout innobase/pars/pars0opt.c: Output to stderr instead of stdout innobase/rem/rem0rec.c: Remove rec_sprintf() Output to stderr instead of stdout innobase/row/row0ins.c: Output diagnostics to stream instead of memory buffer innobase/row/row0mysql.c: Output to stderr instead of stdout Quote table and index names innobase/row/row0purge.c: Output to stderr instead of stdout innobase/row/row0row.c: Quote table and index names innobase/row/row0sel.c: Output to stderr instead of stdout Quote table and index names innobase/row/row0umod.c: Avoid sprintf() Quote table and index names innobase/row/row0undo.c: Output to stderr instead of stdout innobase/row/row0upd.c: Avoid sprintf() innobase/srv/srv0srv.c: Output to stderr instead of stdout innobase/srv/srv0start.c: Handle srv_monitor_file Make some global variables static innobase/sync/sync0arr.c: Output to stderr instead of stdout Output to stream instead of memory buffer innobase/sync/sync0rw.c: Output to stderr instead of stdout innobase/sync/sync0sync.c: Output to stderr instead of stdout Output to stream instead of memory buffer innobase/trx/trx0purge.c: Output to stderr instead of stdout innobase/trx/trx0rec.c: Quote index and table names Avoid sprintf() innobase/trx/trx0roll.c: Quote identifier names Output to stderr instead of stdout innobase/trx/trx0sys.c: Output to stderr instead of stdout innobase/trx/trx0trx.c: Output to stream instead of memory buffer innobase/trx/trx0undo.c: Output to stderr instead of stdout innobase/ut/ut0ut.c: Declare mysql_get_identifier_quote_char() Remove ut_sprintf_buf() Add ut_print_name() and ut_print_namel() Add ut_copy_file() sql/ha_innodb.cc: innobase_mysql_print_thd(): output to stream, not to memory buffer Add mysql_get_identifier_quote_char() Remove unused function innobase_print_error() Display pointers with %p Buffer InnoDB output via files, not via statically allocated memory --- innobase/include/buf0buf.h | 3 +-- innobase/include/buf0buf.ic | 18 +++++++++--------- innobase/include/data0data.h | 11 +---------- innobase/include/dict0dict.h | 28 ++++++++++++++-------------- innobase/include/ha0ha.h | 3 +-- innobase/include/ibuf0ibuf.h | 3 +-- innobase/include/lock0lock.h | 11 +++++------ innobase/include/log0log.h | 3 +-- innobase/include/mtr0log.ic | 7 ++++--- innobase/include/os0file.h | 3 +-- innobase/include/rem0rec.h | 11 +---------- innobase/include/rem0rec.ic | 2 +- innobase/include/row0sel.ic | 5 +---- innobase/include/row0upd.ic | 8 +++++--- innobase/include/srv0srv.h | 14 +++++++++----- innobase/include/sync0arr.h | 3 +-- innobase/include/sync0sync.h | 6 ++---- innobase/include/trx0sys.h | 2 +- innobase/include/trx0trx.h | 3 +-- innobase/include/ut0ut.h | 42 ++++++++++++++++++++++++++++++------------ 20 files changed, 90 insertions(+), 96 deletions(-) (limited to 'innobase/include') diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h index 72cedafa7e1..5ac9c83a5f9 100644 --- a/innobase/include/buf0buf.h +++ b/innobase/include/buf0buf.h @@ -483,8 +483,7 @@ Prints info of the buffer i/o. */ void buf_print_io( /*=========*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end);/* in: buffer end */ + FILE* file); /* in: file where to print */ /************************************************************************* Returns the ratio in percents of modified pages in the buffer pool / database pages in the buffer pool. */ diff --git a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic index 5a4c56b0c30..16deade0901 100644 --- a/innobase/include/buf0buf.ic +++ b/innobase/include/buf0buf.ic @@ -217,9 +217,9 @@ buf_block_align( || block >= buf_pool->blocks + buf_pool->max_size) { fprintf(stderr, -"InnoDB: Error: trying to access a stray pointer %lx\n" -"InnoDB: buf pool start is at %lx, number of pages %lu\n", (ulint)ptr, - (ulint)frame_zero, buf_pool->max_size); +"InnoDB: Error: trying to access a stray pointer %p\n" +"InnoDB: buf pool start is at %p, number of pages %lu\n", ptr, + frame_zero, buf_pool->max_size); ut_error; } @@ -251,9 +251,9 @@ buf_block_align_low( || block >= buf_pool->blocks + buf_pool->max_size) { fprintf(stderr, -"InnoDB: Error: trying to access a stray pointer %lx\n" -"InnoDB: buf pool start is at %lx, number of pages %lu\n", (ulint)ptr, - (ulint)frame_zero, buf_pool->max_size); +"InnoDB: Error: trying to access a stray pointer %p\n" +"InnoDB: buf pool start is at %p, number of pages %lu\n", ptr, + frame_zero, buf_pool->max_size); ut_error; } @@ -280,9 +280,9 @@ buf_frame_align( || ((ulint)frame > (ulint)(buf_pool_get_nth_block(buf_pool, buf_pool->max_size - 1)->frame))) { fprintf(stderr, -"InnoDB: Error: trying to access a stray pointer %lx\n" -"InnoDB: buf pool start is at %lx, number of pages %lu\n", (ulint)ptr, - (ulint)(buf_pool->frame_zero), buf_pool->max_size); +"InnoDB: Error: trying to access a stray pointer %p\n" +"InnoDB: buf pool start is at %p, number of pages %lu\n", ptr, + buf_pool->frame_zero, buf_pool->max_size); ut_error; } diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h index b100ef5b583..99d3c297039 100644 --- a/innobase/include/data0data.h +++ b/innobase/include/data0data.h @@ -326,16 +326,7 @@ The following function prints the contents of a tuple. */ void dtuple_print( /*=========*/ - dtuple_t* tuple); /* in: tuple */ -/************************************************************** -The following function prints the contents of a tuple to a buffer. */ - -ulint -dtuple_sprintf( -/*===========*/ - /* out: printed length in bytes */ - char* buf, /* in: print buffer */ - ulint buf_len,/* in: buf length in bytes */ + FILE* f, /* in: output stream */ dtuple_t* tuple); /* in: tuple */ /****************************************************************** Moves parts of long fields in entry to the big record vector so that diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index 7d7739021e2..835c2c2b2e6 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -331,19 +331,23 @@ dict_print_info_on_foreign_keys( a format suitable to be inserted into a CREATE TABLE, otherwise in the format of SHOW TABLE STATUS */ - char* str, /* in/out: pointer to a string */ - ulint len, /* in: space in str available for info */ + FILE* file, /* in: file where to print */ dict_table_t* table); /* in: table */ /************************************************************************** -Sprintfs to a string info on a foreign key of a table in a format suitable -for CREATE TABLE. */ - -char* +Outputs info on a foreign key of a table in a format suitable for +CREATE TABLE. */ +void dict_print_info_on_foreign_key_in_create_format( /*============================================*/ - /* out: how far in buf we printed */ - dict_foreign_t* foreign,/* in: foreign key constraint */ - char* buf); /* in: buffer of at least 5000 bytes */ + FILE* file, /* in: file where to print */ + dict_foreign_t* foreign);/* in: foreign key constraint */ +/************************************************************************ +Displays the names of the index and the table. */ +void +dict_index_name_print( +/*==================*/ + FILE* file, /* in: output stream */ + const dict_index_t* index); /* in: index to print */ /************************************************************************ Gets the first index on the table (the clustered index). */ UNIV_INLINE @@ -846,13 +850,9 @@ dict_tables_have_same_db( const char* name2); /* in: table name in the form dbname '/' tablename */ -/* The following len must be at least 10000 bytes! */ -#define DICT_FOREIGN_ERR_BUF_LEN 10000 - /* Buffers for storing detailed information about the latest foreign key and unique key errors */ -extern char* dict_foreign_err_buf; -extern char* dict_unique_err_buf; +extern FILE* dict_foreign_err_file; extern mutex_t dict_foreign_err_mutex; /* mutex protecting the buffers */ extern dict_sys_t* dict_sys; /* the dictionary system */ diff --git a/innobase/include/ha0ha.h b/innobase/include/ha0ha.h index 0beac928b7e..908db0a6f26 100644 --- a/innobase/include/ha0ha.h +++ b/innobase/include/ha0ha.h @@ -127,8 +127,7 @@ Prints info of a hash table. */ void ha_print_info( /*==========*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end,/* in: buffer end */ + FILE* file, /* in: file where to print */ hash_table_t* table); /* in: hash table */ /* The hash table external chain node */ diff --git a/innobase/include/ibuf0ibuf.h b/innobase/include/ibuf0ibuf.h index a64eb53bd19..80958a593cb 100644 --- a/innobase/include/ibuf0ibuf.h +++ b/innobase/include/ibuf0ibuf.h @@ -262,8 +262,7 @@ Prints info of ibuf. */ void ibuf_print( /*=======*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end);/* in: buffer end */ + FILE* file); /* in: file where to print */ #define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO #define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h index 103d28cd130..94ef3b33ebc 100644 --- a/innobase/include/lock0lock.h +++ b/innobase/include/lock0lock.h @@ -20,6 +20,8 @@ Created 5/7/1996 Heikki Tuuri #include "hash0hash.h" extern ibool lock_print_waits; +/* Buffer for storing information about the most recent deadlock error */ +extern FILE* lock_latest_err_file; /************************************************************************* Gets the size of a lock struct. */ @@ -468,8 +470,7 @@ Prints info of a table lock. */ void lock_table_print( /*=============*/ - char* buf, /* in/out: buffer where to print, must be at least - 500 bytes */ + FILE* file, /* in: file where to print */ lock_t* lock); /* in: table type lock */ /************************************************************************* Prints info of a record lock. */ @@ -477,8 +478,7 @@ Prints info of a record lock. */ void lock_rec_print( /*===========*/ - char* buf, /* in/out: buffer where to print, must be at least - 500 bytes */ + FILE* file, /* in: file where to print */ lock_t* lock); /* in: record type lock */ /************************************************************************* Prints info of locks for all transactions. */ @@ -486,8 +486,7 @@ Prints info of locks for all transactions. */ void lock_print_info( /*============*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end);/* in: buffer end */ + FILE* file); /* in: file where to print */ /************************************************************************* Validates the lock queue on a table. */ diff --git a/innobase/include/log0log.h b/innobase/include/log0log.h index 3295bc2d231..6eef8144c27 100644 --- a/innobase/include/log0log.h +++ b/innobase/include/log0log.h @@ -512,8 +512,7 @@ Prints info of the log. */ void log_print( /*======*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end);/* in: buffer end */ + FILE* file); /* in: file where to print */ /********************************************************** Peeks the current lsn. */ diff --git a/innobase/include/mtr0log.ic b/innobase/include/mtr0log.ic index 54f15779078..ad40fa525db 100644 --- a/innobase/include/mtr0log.ic +++ b/innobase/include/mtr0log.ic @@ -165,8 +165,8 @@ mlog_write_initial_log_record_fast( if (space != 0 || offset > 0x8FFFFFFF) { fprintf(stderr, - "InnoDB: error: buffer page pointer %lx has nonsensical space id %lu\n" - "InnoDB: or page no %lu\n", (ulint)ptr, space, offset); + "InnoDB: error: buffer page pointer %p has nonsensical space id %lu\n" + "InnoDB: or page no %lu\n", ptr, space, offset); ut_error; } @@ -178,7 +178,8 @@ mlog_write_initial_log_record_fast( mtr->n_log_recs++; #ifdef UNIV_LOG_DEBUG -/* printf("Adding to mtr log record type %lu space %lu page no %lu\n", +/* fprintf(stderr, + "Adding to mtr log record type %lu space %lu page no %lu\n", type, space, offset); */ #endif diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index b221bf7aef9..108cf5520f1 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -443,8 +443,7 @@ Prints info of the aio arrays. */ void os_aio_print( /*=========*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end);/* in: buffer end */ + FILE* file); /* in: file where to print */ /************************************************************************** Refreshes the statistics used to print per-second averages. */ diff --git a/innobase/include/rem0rec.h b/innobase/include/rem0rec.h index b28f39925c1..ff9d1495198 100644 --- a/innobase/include/rem0rec.h +++ b/innobase/include/rem0rec.h @@ -390,16 +390,7 @@ Prints a physical record. */ void rec_print( /*======*/ - rec_t* rec); /* in: physical record */ -/******************************************************************* -Prints a physical record to a buffer. */ - -ulint -rec_sprintf( -/*========*/ - /* out: printed length in bytes */ - char* buf, /* in: buffer to print to */ - ulint buf_len,/* in: buffer length */ + FILE* file, /* in: file where to print */ rec_t* rec); /* in: physical record */ #define REC_INFO_BITS 6 /* This is single byte bit-field */ diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic index 9dfd4faeec8..75a8bdfd6bd 100644 --- a/innobase/include/rem0rec.ic +++ b/innobase/include/rem0rec.ic @@ -190,7 +190,7 @@ rec_set_bit_field_2( + (REC_N_OWNED_MASK << (8 * (REC_N_OWNED - 3))) + (REC_INFO_BITS_MASK << (8 * (REC_INFO_BITS - 3)))); if (m != ut_dbg_zero + 0xFFFFFFFF) { - printf("Sum of masks %lx\n", m); + fprintf(stderr, "Sum of masks %lx\n", m); ut_error; } } diff --git a/innobase/include/row0sel.ic b/innobase/include/row0sel.ic index 9005624b6ca..509838a3327 100644 --- a/innobase/include/row0sel.ic +++ b/innobase/include/row0sel.ic @@ -77,12 +77,9 @@ open_step( if (err != DB_SUCCESS) { /* SQL error detected */ - printf("SQL error %lu\n", err); + fprintf(stderr, "SQL error %lu\n", err); ut_error; - que_thr_handle_error(thr, err, NULL, 0); - - return(NULL); } thr->run_node = que_node_get_parent(node); diff --git a/innobase/include/row0upd.ic b/innobase/include/row0upd.ic index 3e00978be2f..65667f1f00d 100644 --- a/innobase/include/row0upd.ic +++ b/innobase/include/row0upd.ic @@ -84,9 +84,11 @@ upd_field_set_field_no( if (field_no >= dict_index_get_n_fields(index)) { fprintf(stderr, - "InnoDB: Error: trying to access field %lu in table %s\n" - "InnoDB: index %s, but index has only %lu fields\n", - field_no, index->table_name, index->name, + "InnoDB: Error: trying to access field %lu in ", + field_no); + dict_index_name_print(stderr, index); + fprintf(stderr, "\n" + "InnoDB: but index only has %lu fields\n", dict_index_get_n_fields(index)); } diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 3811f6ae167..40a96e79973 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -32,6 +32,11 @@ at a time */ /* This is set to TRUE if the MySQL user has set it in MySQL */ extern ibool srv_lower_case_table_names; +/* Mutex for locking srv_monitor_file */ +extern mutex_t srv_monitor_file_mutex; +/* Temporary file for innodb monitor output */ +extern FILE* srv_monitor_file; + /* Server parameters which are read from the initfile */ extern char* srv_data_home; @@ -368,13 +373,12 @@ srv_error_monitor_thread( void* arg); /* in: a dummy parameter required by os_thread_create */ /********************************************************************** -Sprintfs to a buffer the output of the InnoDB Monitor. */ +Outputs to a file the output of the InnoDB Monitor. */ void -srv_sprintf_innodb_monitor( -/*=======================*/ - char* buf, /* in/out: buffer which must be at least 4 kB */ - ulint len); /* in: length of the buffer */ +srv_printf_innodb_monitor( +/*======================*/ + FILE* file); /* in: output stream */ /* Types for the threads existing in the system. Threads of types 4 - 9 diff --git a/innobase/include/sync0arr.h b/innobase/include/sync0arr.h index 765ad33afea..383d0c69fb2 100644 --- a/innobase/include/sync0arr.h +++ b/innobase/include/sync0arr.h @@ -114,8 +114,7 @@ Prints info of the wait array. */ void sync_array_print_info( /*==================*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end,/* in: buffer end */ + FILE* file, /* in: file where to print */ sync_array_t* arr); /* in: wait array */ diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h index 3acf3415889..3348da2851c 100644 --- a/innobase/include/sync0sync.h +++ b/innobase/include/sync0sync.h @@ -119,16 +119,14 @@ Prints wait info of the sync system. */ void sync_print_wait_info( /*=================*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end); /* in: buffer end */ + FILE* file); /* in: file where to print */ /*********************************************************************** Prints info of the sync system. */ void sync_print( /*=======*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end); /* in: buffer end */ + FILE* file); /* in: file where to print */ /********************************************************************** Checks that the mutex has been initialized. */ diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h index a8ed675a8a5..755bcb28611 100644 --- a/innobase/include/trx0sys.h +++ b/innobase/include/trx0sys.h @@ -269,7 +269,7 @@ void trx_sys_print_mysql_binlog_offset(void); /*===================================*/ /********************************************************************* -Prints to stdout the MySQL binlog info in the system header if the +Prints to stderr the MySQL binlog info in the system header if the magic number shows it valid. */ void diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index d9b91ee62dc..bb2d7e8f64d 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -280,8 +280,7 @@ own the kernel mutex. */ void trx_print( /*======*/ - char* buf, /* in/out: buffer where to print, must be at least - 800 bytes */ + FILE* f, /* in: output stream */ trx_t* trx); /* in: transaction */ diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h index 637c9a68174..b349fe26015 100644 --- a/innobase/include/ut0ut.h +++ b/innobase/include/ut0ut.h @@ -169,7 +169,7 @@ ut_print_timestamp( /*===============*/ FILE* file); /* in: file where to print */ /************************************************************** -Sprintfs a timestamp to a buffer. */ +Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */ void ut_sprintf_timestamp( @@ -199,19 +199,37 @@ Prints the contents of a memory buffer in hex and ascii. */ void ut_print_buf( /*=========*/ - byte* buf, /* in: memory buffer */ - ulint len); /* in: length of the buffer */ -/***************************************************************** -Prints the contents of a memory buffer in hex and ascii. */ + FILE* file, /* in: file where to print */ + const byte* buf, /* in: memory buffer */ + ulint len); /* in: length of the buffer */ -ulint -ut_sprintf_buf( -/*===========*/ - /* out: printed length in bytes */ - char* str, /* in: buffer to print to */ - byte* buf, /* in: memory buffer */ - ulint len); /* in: length of the buffer */ +/************************************************************************** +Outputs a NUL-terminated string, quoted as an SQL identifier. */ + +void +ut_print_name( +/*==========*/ + FILE* f, /* in: output stream */ + const char* name); /* in: name to print */ + +/************************************************************************** +Outputs a fixed-length string, quoted as an SQL identifier. */ +void +ut_print_namel( +/*==========*/ + FILE* f, /* in: output stream */ + const char* name, /* in: name to print */ + ulint namelen);/* in: length of name */ + +/************************************************************************** +Catenate files. */ + +void +ut_copy_file( +/*=========*/ + FILE* dest, /* in: output file */ + FILE* src); /* in: input file to be appended to output */ #ifndef UNIV_NONINL #include "ut0ut.ic" -- cgit v1.2.1