Commit 751ca014 authored by unknown's avatar unknown

Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into lmy004.:/work/mysql-5.1-bug17289

parents 79765df9 2d94ee29
......@@ -730,10 +730,10 @@ build_query_string(void)
strmov(ptr->string, query_string.str);
DBUG_PRINT("info", ("user_supplied_query %s", ptr->string));
dynstr_free(&query_string);
DBUG_RETURN(0);
DBUG_RETURN(ptr);
}
static int
static int
get_options(int *argc,char ***argv)
{
int ho_error;
......
......@@ -1856,7 +1856,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
realpath rename rint rwlock_init setupterm \
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
sighold sigset sigthreadmask \
sighold sigset sigthreadmask sleep \
snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr strtol \
strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
posix_fallocate)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Some extra options to DBUG_PUSH:
O,logfile - As in "o,logfile", but do a close and reopen each time anything
is written to the logfile. This is needed when one expects
the program to crash anywhere, in which case one doesn't
(at least in MSDOS) get a full log-file.
If one wants a logfile with a ':' in the filename, one can get it by
giving a double ':'. (As in "O,c::\tmp\log")
DBUG_DUMP("keyword",memory-position,length) writes a hexdump of the
given memory-area to the outputfile.
All changes that I or other people at MySQL AB have done to all files
in the dbug library (Mainly in dbug.c, dbug_analyze.c, dbug_long.h,
......@@ -18,3 +6,4 @@ dbug.h) are put in public domain, as the rest of the dbug.c library)
To my knowledge, all code in dbug library is in public domain.
Michael Widenius
Hi,
I'm sending you the modifications I made to your Dbug routines to
allow profiling in a (relatively) machine independent fashion.
I use your Dbug routines fairly extensively. Unfortunately, it's
a royal pain to have to keep profiled versions of various libraries
around. The modifications allow profiling without the need for this.
How it works.
------------
Basically, I just added code in the dbug routines to write out a file
called dbugmon.out (by default). This is an ascii file containing lines
of the form:
<function-name> E <time-entered>
<function-name> X <time-exited>
A second program (analyze) reads this file, and produces a report on
standard output.
Profiling is enabled through the `g' flag. It can take a list of
procedure names for which profiling is enabled. By default, it
profiles all procedures.
The code in ``dbug.c'' opens the profile file for appending. This
is in order that one can run a program several times, and get the
sum total of all the times, etc.
The only system dependent part that I'm aware of is the routine
Clock() at the end of dbug.c. This returns the elapsed user time
in milliseconds. The version which I have is for 4.3 BSD. As I
don't have access to other systems, I'm not certain how this would
change.
An example of the report generated follows:
Profile of Execution
Execution times are in milliseconds
Calls Time
----- ----
Times Percentage Time Spent Percentage
Function Called of total in Function of total Importance
======== ====== ========== =========== ========== ==========
factorial 5 83.33 30 100.00 8333
main 1 16.67 0 0.00 0
======== ====== ========== =========== ==========
Totals 6 100.00 30 100.00
As you can see, it's quite self-evident. The ``Importance'' column is a
metric obtained by multiplying the percentage of the calls and the percentage
of the time. Functions with higher 'importance' benefit the most from
being sped up.
I'm really not certain how to add support for setjmp/longjmp, or for
child processes, so I've ignored that for the time being. In most of
the code that I write, it isn't necessary. If you have any good ideas,
feel free to add them.
This has been very useful to me. If you can use it as part of your
dbug distribution, please feel free to do so.
Regards,
Binayak Banerjee
{allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje
bbanerje%sjuvax.sju.edu@relay.cs.net
July 9, 1987
This diff is collapsed.
......@@ -21,15 +21,18 @@
extern "C" {
#endif
#if !defined(DBUG_OFF) && !defined(_lint)
extern int _db_on_,_no_db_;
extern FILE *_db_fp_;
extern char *_db_process_;
extern int _db_keyword_(const char *keyword);
struct _db_code_state_;
extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
extern int _db_strict_keyword_(const char *keyword);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, int len);
extern int _db_explain_init_(char *buf, int len);
extern void _db_setjmp_(void);
extern void _db_longjmp_(void);
extern void _db_process_(const char *name);
extern void _db_push_(const char *control);
extern void _db_pop_(void);
extern void _db_set_(struct _db_code_state_ *cs, const char *control);
extern void _db_set_init_(const char *control);
extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
const char **_sfunc_,const char **_sfile_,
uint *_slevel_, char ***);
......@@ -39,61 +42,66 @@ extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...));
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
uint length);
extern void _db_output_(uint flag);
extern void _db_lock_file(void);
extern void _db_unlock_file(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
char **_db_framep_; \
_db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
&_db_framep_)
#define DBUG_LEAVE \
(_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}
#define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
#define DBUG_EXECUTE(keyword,a1) \
{if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
#define DBUG_EXECUTE_IF(keyword,a1) \
do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) \
(_db_keyword_(0,(keyword)) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_strict_keyword_((keyword)) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
{if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_PROCESS(a1) (_db_process_ = a1)
#define DBUG_FILE (_db_fp_)
#define DBUG_SET(a1) _db_set_ (0, (a1))
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
#define DBUG_PROCESS(a1) _db_process_(a1)
#define DBUG_FILE _db_fp_()
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
#define DBUG_DUMP(keyword,a1,a2)\
{if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}}
#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
#define DEBUGGER_ON _no_db_=0
#define DBUG_LOCK_FILE { _db_lock_file(); }
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
#define DBUG_OUTPUT(A) { _db_output_(A); }
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
#define DBUG_LOCK_FILE _db_lock_file_()
#define DBUG_UNLOCK_FILE _db_unlock_file_()
#define DBUG_ASSERT(A) assert(A)
#define DBUG_EXECUTE_IF(keyword,a1) \
{if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}}
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
#else /* No debugger */
#define DBUG_ENTER(a1)
#define DBUG_RETURN(a1) return(a1)
#define DBUG_VOID_RETURN return
#define DBUG_EXECUTE(keyword,a1) {}
#define DBUG_EXECUTE_IF(keyword,a1) {}
#define DBUG_PRINT(keyword,arglist) {}
#define DBUG_PUSH(a1) {}
#define DBUG_POP() {}
#define DBUG_PROCESS(a1) {}
#define DBUG_FILE (stderr)
#define DBUG_SETJMP setjmp
#define DBUG_LONGJMP longjmp
#define DBUG_DUMP(keyword,a1,a2) {}
#define DBUG_IN_USE 0
#define DEBUGGER_OFF
#define DEBUGGER_ON
#define DBUG_RETURN(a1) do { return(a1); } while(0)
#define DBUG_VOID_RETURN do { return; } while(0)
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
#define DBUG_PRINT(keyword,arglist) do { } while(0)
#define DBUG_PUSH(a1)
#define DBUG_SET(a1)
#define DBUG_SET_INITIAL(a1)
#define DBUG_POP()
#define DBUG_PROCESS(a1) (a1)
#define DBUG_SETJMP(a1) setjmp(a1)
#define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2)
#define DBUG_ASSERT(A)
#define DBUG_LOCK_FILE
#define DBUG_FILE (stderr)
#define DBUG_UNLOCK_FILE
#define DBUG_OUTPUT(A)
#define DBUG_ASSERT(A) {}
#define DBUG_EXPLAIN(buf,len)
#define DBUG_EXPLAIN_INITIAL(buf,len)
#endif
#ifdef __cplusplus
}
......
......@@ -48,7 +48,7 @@ struct st_mysql_plugin _mysql_plugin_declarations_[]= {
*/
enum enum_mysql_show_type
{
SHOW_UNDEF, SHOW_BOOL, SHOW_MY_BOOL, SHOW_INT, SHOW_LONG,
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC
};
......
......@@ -179,10 +179,8 @@ void STDCALL mysql_server_end()
if (!org_my_init_done)
{
my_end(0);
#ifndef THREAD
/* Remove TRACING, if enabled by mysql_debug() */
DBUG_POP();
#endif
}
else
mysql_thread_end();
......@@ -267,16 +265,12 @@ mysql_debug(const char *debug __attribute__((unused)))
{
#ifndef DBUG_OFF
char *env;
if (_db_on_)
return; /* Already using debugging */
if (debug)
{
DEBUGGER_ON;
DBUG_PUSH(debug);
}
else if ((env = getenv("MYSQL_DEBUG")))
{
DEBUGGER_ON;
DBUG_PUSH(env);
#if !defined(_WINVER) && !defined(WINVER)
puts("\n-------------------------------------------------------");
......
This diff is collapsed.
......@@ -1344,9 +1344,11 @@ CHECK TABLE t2;
SELECT * FROM t2;
# Just test syntax, we will never know if the output is right or wrong
# Must be the last test
# We won't know exactly about what is going on internally,
# but we will see if the row makes it in!!
INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','');
FLUSH TABLE t2;
SELECT * FROM t2;
# Adding test for alter table
ALTER TABLE t2 DROP COLUMN fld6;
......
......@@ -214,6 +214,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
WSACleanup();
#endif /* __WIN__ */
my_init_done=0;
DBUG_VOID_RETURN;
} /* my_end */
......
......@@ -282,7 +282,7 @@ const char *my_thread_name(void)
if (!tmp->name[0])
{
long id=my_thread_id();
sprintf(name_buff,"T@%ld", id);
sprintf(name_buff,"T@%lu", id);
strmake(tmp->name,name_buff,THREAD_NAME_SIZE);
}
return tmp->name;
......
......@@ -250,7 +250,6 @@ static int do_test()
static int get_options(int argc, char **argv)
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -270,7 +269,6 @@ static int get_options(int argc, char **argv)
printf("Usage: %s [-?ABIKLWv] [-m#] [-t#]\n",progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
}
......
......@@ -126,10 +126,10 @@ static HASH archive_open_tables;
#define ARN ".ARN" // Files used during an optimize call
#define ARM ".ARM" // Meta file
/*
uchar + uchar + ulonglong + ulonglong + ulonglong + uchar
uchar + uchar + ulonglong + ulonglong + ulonglong + ulonglong + uchar
*/
#define META_BUFFER_SIZE sizeof(uchar) + sizeof(uchar) + sizeof(ulonglong) \
+ sizeof(ulonglong) + sizeof(ulonglong) + sizeof(uchar)
+ sizeof(ulonglong) + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(uchar)
/*
uchar + uchar
......@@ -313,7 +313,8 @@ int ha_archive::write_data_header(azio_stream *file_to_write)
*rows will contain the current number of rows in the data file upon success.
*/
int ha_archive::read_meta_file(File meta_file, ha_rows *rows,
ulonglong *auto_increment)
ulonglong *auto_increment,
ulonglong *forced_flushes)
{
uchar meta_buffer[META_BUFFER_SIZE];
uchar *ptr= meta_buffer;
......@@ -336,12 +337,15 @@ int ha_archive::read_meta_file(File meta_file, ha_rows *rows,
ptr+= sizeof(ulonglong); // Move past check_point
*auto_increment= uint8korr(ptr);
ptr+= sizeof(ulonglong); // Move past auto_increment
*forced_flushes= uint8korr(ptr);
ptr+= sizeof(ulonglong); // Move past forced_flush
DBUG_PRINT("ha_archive::read_meta_file", ("Check %d", (uint)meta_buffer[0]));
DBUG_PRINT("ha_archive::read_meta_file", ("Version %d", (uint)meta_buffer[1]));
DBUG_PRINT("ha_archive::read_meta_file", ("Rows %llu", *rows));
DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %llu", check_point));
DBUG_PRINT("ha_archive::read_meta_file", ("Auto-Increment %llu", *auto_increment));
DBUG_PRINT("ha_archive::read_meta_file", ("Forced Flushes %llu", *forced_flushes));
DBUG_PRINT("ha_archive::read_meta_file", ("Dirty %d", (int)(*ptr)));
if ((meta_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) ||
......@@ -359,7 +363,9 @@ int ha_archive::read_meta_file(File meta_file, ha_rows *rows,
Upon ::open() we set to dirty, and upon ::close() we set to clean.
*/
int ha_archive::write_meta_file(File meta_file, ha_rows rows,
ulonglong auto_increment, bool dirty)
ulonglong auto_increment,
ulonglong forced_flushes,
bool dirty)
{
uchar meta_buffer[META_BUFFER_SIZE];
uchar *ptr= meta_buffer;
......@@ -377,6 +383,8 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows,
ptr += sizeof(ulonglong);
int8store(ptr, auto_increment);
ptr += sizeof(ulonglong);
int8store(ptr, forced_flushes);
ptr += sizeof(ulonglong);
*ptr= (uchar)dirty;
DBUG_PRINT("ha_archive::write_meta_file", ("Check %d",
(uint)ARCHIVE_CHECK_HEADER));
......@@ -386,6 +394,8 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows,
DBUG_PRINT("ha_archive::write_meta_file", ("Checkpoint %llu", check_point));
DBUG_PRINT("ha_archive::write_meta_file", ("Auto Increment %llu",
auto_increment));
DBUG_PRINT("ha_archive::write_meta_file", ("Forced Flushes %llu",
forced_flushes));
DBUG_PRINT("ha_archive::write_meta_file", ("Dirty %d", (uint)dirty));
VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
......@@ -451,11 +461,14 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name,
leave it up to the user to fix.
*/
if (read_meta_file(share->meta_file, &share->rows_recorded,
&share->auto_increment_value))
&share->auto_increment_value,
&share->forced_flushes))
share->crashed= TRUE;
else
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->auto_increment_value, TRUE);
share->auto_increment_value,
share->forced_flushes,
TRUE);
/*
It is expensive to open and close the data files and since you can't have
a gzip file that can be both read and written we keep a writer open
......@@ -500,12 +513,18 @@ int ha_archive::free_share(ARCHIVE_SHARE *share)
hash_delete(&archive_open_tables, (byte*) share);
thr_lock_delete(&share->lock);
VOID(pthread_mutex_destroy(&share->mutex));
if (share->crashed)
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->auto_increment_value, TRUE);
else
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->auto_increment_value, FALSE);
/*
We need to make sure we don't reset the crashed state.
If we open a crashed file, wee need to close it as crashed unless
it has been repaired.
Since we will close the data down after this, we go on and count
the flush on close;
*/
share->forced_flushes++;
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->auto_increment_value,
share->forced_flushes,
share->crashed ? TRUE :FALSE);
if (azclose(&(share->archive_write)))
rc= 1;
if (my_close(share->meta_file, MYF(0)))
......@@ -657,7 +676,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
}
}
write_meta_file(create_file, 0, auto_increment_value, FALSE);
write_meta_file(create_file, 0, auto_increment_value, 0, FALSE);
my_close(create_file,MYF(0));
/*
......@@ -800,6 +819,7 @@ int ha_archive::write_row(byte *buf)
data
*/
azflush(&(share->archive_write), Z_SYNC_FLUSH);
share->forced_flushes++;
/*
Set the position of the local read thread to the beginning postion.
*/
......@@ -897,6 +917,7 @@ int ha_archive::index_read_idx(byte *buf, uint index, const byte *key,
*/
pthread_mutex_lock(&share->mutex);
azflush(&(share->archive_write), Z_SYNC_FLUSH);
share->forced_flushes++;
pthread_mutex_unlock(&share->mutex);
/*
......@@ -974,6 +995,7 @@ int ha_archive::rnd_init(bool scan)
{
DBUG_PRINT("info", ("archive flushing out rows for scan"));
azflush(&(share->archive_write), Z_SYNC_FLUSH);
share->forced_flushes++;
share->dirty= FALSE;
}
pthread_mutex_unlock(&share->mutex);
......@@ -1149,6 +1171,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
/* Flush any waiting data */
azflush(&(share->archive_write), Z_SYNC_FLUSH);
share->forced_flushes++;
/* Lets create a file to contain the new data */
fn_format(writer_filename, share->table_name, "", ARN,
......@@ -1233,13 +1256,15 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
goto error;
}
while ((read= azread(&archive, block, IO_SIZE)))
while ((read= azread(&archive, block, IO_SIZE)) > 0)
azwrite(&writer, block, read);
}
azclose(&writer);
share->dirty= FALSE;
share->forced_flushes= 0;
azclose(&(share->archive_write));
DBUG_PRINT("info", ("Reopening archive data file"));
if (!(azopen(&(share->archive_write), share->data_file_name,
O_WRONLY|O_APPEND|O_BINARY)))
{
......@@ -1421,6 +1446,7 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
thd->proc_info= "Checking table";
/* Flush any waiting data */
azflush(&(share->archive_write), Z_SYNC_FLUSH);
share->forced_flushes++;
/*
First we create a buffer that we can use for reading rows, and can pass
......
......@@ -39,6 +39,8 @@ typedef struct st_archive_share {
bool crashed; /* Meta file is crashed */
ha_rows rows_recorded; /* Number of rows in tables */
ulonglong auto_increment_value;
ulonglong forced_flushes;
ulonglong mean_rec_length;
} ARCHIVE_SHARE;
/*
......@@ -98,9 +100,13 @@ class ha_archive: public handler
int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos);
int get_row(azio_stream *file_to_read, byte *buf);
int read_meta_file(File meta_file, ha_rows *rows, ulonglong *auto_increment);
int read_meta_file(File meta_file, ha_rows *rows,
ulonglong *auto_increment,
ulonglong *forced_flushes);
int write_meta_file(File meta_file, ha_rows rows,
ulonglong auto_increment, bool dirty);
ulonglong auto_increment,
ulonglong forced_flushes,
bool dirty);
ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table, int *rc);
int free_share(ARCHIVE_SHARE *share);
bool auto_repair() const { return 1; } // For the moment we just do this
......
......@@ -116,7 +116,7 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
DBUG_PRINT("info", ("ha_myisammrg::open exit %d", my_errno));
return (my_errno ? my_errno : -1);
}
DBUG_PRINT("info", ("ha_myisammrg::open myrg_extrafunc..."))
DBUG_PRINT("info", ("ha_myisammrg::open myrg_extrafunc..."));
myrg_extrafunc(file, query_cache_invalidate_by_MyISAM_filename_ref);
if (!(test_if_locked == HA_OPEN_WAIT_IF_LOCKED ||
test_if_locked == HA_OPEN_ABORT_IF_LOCKED))
......
......@@ -2795,7 +2795,7 @@ void ndb_unpack_record(TABLE *table, NdbValue *value,
ndb_blob->getDefined(isNull);
if (isNull == 1)
{
DBUG_PRINT("info",("[%u] NULL", col_no))
DBUG_PRINT("info",("[%u] NULL", col_no));
field->set_null(row_offset);
}
else if (isNull == -1)
......@@ -2833,15 +2833,18 @@ void ha_ndbcluster::unpack_record(byte *buf)
const NDBCOL *hidden_col= tab->getColumn(hidden_no);
const NdbRecAttr* rec= m_value[hidden_no].rec;
DBUG_ASSERT(rec);
DBUG_PRINT("hidden", ("%d: %s \"%llu\"", hidden_no,
DBUG_PRINT("hidden", ("%d: %s \"%llu\"", hidden_no,
hidden_col->getName(), rec->u_64_value()));
}
//print_results();
}
//DBUG_EXECUTE("value", print_results(););
#endif
}
/*
Utility function to print/dump the fetched field
to avoid unnecessary work, wrap in DBUG_EXECUTE as in:
DBUG_EXECUTE("value", print_results(););
*/
void ha_ndbcluster::print_results()
......@@ -2849,8 +2852,6 @@ void ha_ndbcluster::print_results()
DBUG_ENTER("print_results");
#ifndef DBUG_OFF
if (!_db_on_)
DBUG_VOID_RETURN;
char buf_type[MAX_FIELD_WIDTH], buf_val[MAX_FIELD_WIDTH];
String type(buf_type, sizeof(buf_type), &my_charset_bin);
......@@ -6450,7 +6451,7 @@ ha_ndbcluster::register_query_cache_table(THD *thd,
if (!is_autocommit)
{
DBUG_PRINT("exit", ("Can't register table during transaction"))
DBUG_PRINT("exit", ("Can't register table during transaction"));
DBUG_RETURN(FALSE);
}
......@@ -6458,7 +6459,7 @@ ha_ndbcluster::register_query_cache_table(THD *thd,
if (ndb_get_commitcount(thd, m_dbname, m_tabname, &commit_count))
{
*engine_data= 0;
DBUG_PRINT("exit", ("Error, could not get commitcount"))
DBUG_PRINT("exit", ("Error, could not get commitcount"));
DBUG_RETURN(FALSE);
}
*engine_data= commit_count;
......
......@@ -101,24 +101,21 @@ static TABLE_LIST binlog_tables;
#ifndef DBUG_OFF
static void print_records(TABLE *table, const char *record)
{
if (_db_on_)
for (uint j= 0; j < table->s->fields; j++)
{
for (uint j= 0; j < table->s->fields; j++)
char buf[40];
int pos= 0;
Field *field= table->field[j];
const byte* field_ptr= field->ptr - table->record[0] + record;
int pack_len= field->pack_length();
int n= pack_len < 10 ? pack_len : 10;
for (int i= 0; i < n && pos < 20; i++)
{
char buf[40];
int pos= 0;
Field *field= table->field[j];
const byte* field_ptr= field->ptr - table->record[0] + record;
int pack_len= field->pack_length();
int n= pack_len < 10 ? pack_len : 10;
for (int i= 0; i < n && pos < 20; i++)
{
pos+= sprintf(&buf[pos]," %x", (int) (unsigned char) field_ptr[i]);
}
buf[pos]= 0;
DBUG_PRINT("info",("[%u]field_ptr[0->%d]: %s", j, n, buf));
pos+= sprintf(&buf[pos]," %x", (int) (unsigned char) field_ptr[i]);
}
buf[pos]= 0;
DBUG_PRINT("info",("[%u]field_ptr[0->%d]: %s", j, n, buf));
}
}
#else
......@@ -2490,7 +2487,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
DBUG_ASSERT(ret == 0);
}
ndb_unpack_record(table, share->ndb_value[n], &b, table->record[n]);
print_records(table, table->record[n]);
DBUG_EXECUTE("info", print_records(table, table->record[n]););
trans.delete_row(::server_id, injector::transaction::table(table, true),
&b, n_fields, table->record[n]);
}
......@@ -2509,7 +2506,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
}
ndb_unpack_record(table, share->ndb_value[0],
&b, table->record[0]);
print_records(table, table->record[0]);
DBUG_EXECUTE("info", print_records(table, table->record[0]););
if (table->s->primary_key != MAX_KEY)
{
/*
......@@ -2534,7 +2531,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
DBUG_ASSERT(ret == 0);
}
ndb_unpack_record(table, share->ndb_value[1], &b, table->record[1]);
print_records(table, table->record[1]);
DBUG_EXECUTE("info", print_records(table, table->record[1]););
trans.update_row(::server_id,
injector::transaction::table(table, true),
&b, n_fields,
......
......@@ -2861,7 +2861,7 @@ longlong Item_is_not_null_test::val_int()
}
if (args[0]->is_null())
{
DBUG_PRINT("info", ("null"))
DBUG_PRINT("info", ("null"));
owner->was_null|= 1;
DBUG_RETURN(0);
}
......
......@@ -622,7 +622,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
table_ptr[i], count,
(thd == logger.get_general_log_thd()) ||
(thd == logger.get_slow_log_thd())))
return 0;
DBUG_RETURN(0);
}
if (!(sql_lock= (MYSQL_LOCK*)
......
......@@ -5659,7 +5659,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
m_data_size= TABLE_MAP_HEADER_LEN;
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;)
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;);
m_data_size+= m_dblen + 2; // Include length and terminating \0
m_data_size+= m_tbllen + 2; // Include length and terminating \0
m_data_size+= 1 + m_colcnt; // COLCNT and column types
......
......@@ -1094,12 +1094,8 @@ pthread_handler_t kill_server_thread(void *arg __attribute__((unused)))
extern "C" sig_handler print_signal_warning(int sig)
{
if (!DBUG_IN_USE)
{
if (global_system_variables.log_warnings)
sql_print_warning("Got signal %d from thread %d",
sig,my_thread_id());
}
if (global_system_variables.log_warnings)
sql_print_warning("Got signal %d from thread %d", sig,my_thread_id());
#ifdef DONT_REMEMBER_SIGNAL
my_sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
......@@ -1720,7 +1716,7 @@ void end_thread(THD *thd, bool put_in_cache)
! abort_loop && !kill_cached_threads)
{
/* Don't kill the thread, just put it in cache for reuse */
DBUG_PRINT("info", ("Adding thread to cache"))
DBUG_PRINT("info", ("Adding thread to cache"));
cached_thread_count++;
while (!abort_loop && ! wake_thread && ! kill_cached_threads)
(void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
......@@ -1741,13 +1737,13 @@ void end_thread(THD *thd, bool put_in_cache)
}
}
DBUG_PRINT("info", ("sending a broadcast"))
DBUG_PRINT("info", ("sending a broadcast"));
/* Tell main we are ready */
(void) pthread_mutex_unlock(&LOCK_thread_count);
/* It's safe to broadcast outside a lock (COND... is not deleted here) */
(void) pthread_cond_broadcast(&COND_thread_count);
DBUG_PRINT("info", ("unlocked thread_count mutex"))
DBUG_PRINT("info", ("unlocked thread_count mutex"));
#ifdef ONE_THREAD
if (!(test_flags & TEST_NO_THREADS)) // For debugging under Linux
#endif
......@@ -3484,8 +3480,6 @@ int win_main(int argc, char **argv)
int main(int argc, char **argv)
#endif
{
DEBUGGER_OFF;
rpl_filter= new Rpl_filter;
binlog_filter= new Rpl_filter;
if (!rpl_filter || !binlog_filter)
......@@ -7076,7 +7070,6 @@ static void mysql_init_variables(void)
max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
global_system_variables.old_passwords= 0;
global_system_variables.old_alter_table= 0;
/*
Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
when collecting index statistics for MyISAM tables.
......@@ -7178,7 +7171,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
switch(optid) {
case '#':
#ifndef DBUG_OFF
DBUG_PUSH(argument ? argument : default_dbug_option);
DBUG_SET(argument ? argument : default_dbug_option);
DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
#endif
opt_endinfo=1; /* unireg: memory allocation */
break;
......
......@@ -10163,8 +10163,6 @@ static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map,
int idx;
char buff[1024];
DBUG_ENTER("print_sel_tree");
if (! _db_on_)
DBUG_VOID_RETURN;
String tmp(buff,sizeof(buff),&my_charset_bin);
tmp.length(0);
......@@ -10193,9 +10191,7 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
struct st_ror_scan_info **start,
struct st_ror_scan_info **end)
{
DBUG_ENTER("print_ror_scans");
if (! _db_on_)
DBUG_VOID_RETURN;
DBUG_ENTER("print_ror_scans_arr");
char buff[1024];
String tmp(buff,sizeof(buff),&my_charset_bin);
......@@ -10259,7 +10255,7 @@ static void print_quick(QUICK_SELECT_I *quick, const key_map *needed_reg)
{
char buf[MAX_KEY/8+1];
DBUG_ENTER("print_quick");
if (! _db_on_ || !quick)
if (!quick)
DBUG_VOID_RETURN;
DBUG_LOCK_FILE;
......
......@@ -205,6 +205,9 @@ sys_var_long_ptr sys_concurrent_insert("concurrent_insert",
&myisam_concurrent_insert);
sys_var_long_ptr sys_connect_timeout("connect_timeout",
&connect_timeout);
#ifndef DBUG_OFF
sys_var_thd_dbug sys_dbug("debug");
#endif
sys_var_enum sys_delay_key_write("delay_key_write",
&delay_key_write_options,
&delay_key_write_typelib,
......@@ -720,13 +723,16 @@ SHOW_VAR init_vars[]= {
{"datadir", mysql_real_data_home, SHOW_CHAR},
{sys_date_format.name, (char*) &sys_date_format, SHOW_SYS},
{sys_datetime_format.name, (char*) &sys_datetime_format, SHOW_SYS},
#ifndef DBUG_OFF
{sys_dbug.name, (char*) &sys_dbug, SHOW_SYS},
#endif
{sys_default_week_format.name, (char*) &sys_default_week_format, SHOW_SYS},
{sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS},
{sys_delayed_insert_limit.name, (char*) &sys_delayed_insert_limit,SHOW_SYS},
{sys_delayed_insert_timeout.name, (char*) &sys_delayed_insert_timeout, SHOW_SYS},
{sys_delayed_queue_size.name,(char*) &sys_delayed_queue_size, SHOW_SYS},
{sys_div_precincrement.name,(char*) &sys_div_precincrement,SHOW_SYS},
{sys_engine_condition_pushdown.name,
{sys_engine_condition_pushdown.name,
(char*) &sys_engine_condition_pushdown, SHOW_SYS},
{sys_event_executor.name, (char*) &sys_event_executor, SHOW_SYS},
{sys_expire_logs_days.name, (char*) &sys_expire_logs_days, SHOW_SYS},
......@@ -3457,6 +3463,33 @@ bool sys_var_trust_routine_creators::update(THD *thd, set_var *var)
return sys_var_bool_ptr::update(thd, var);
}
/* even session variable here requires SUPER, because of -#o,file */
bool sys_var_thd_dbug::check(THD *thd, set_var *var)
{
return check_global_access(thd, SUPER_ACL);
}
bool sys_var_thd_dbug::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : "");
else
{
DBUG_POP();
DBUG_PUSH(var ? var->value->str_value.c_ptr() : "");
}
return 0;
}
byte *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
{
char buf[256];
if (type == OPT_GLOBAL)
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
else
DBUG_EXPLAIN(buf, sizeof(buf));
(byte*) thd->strdup(buf);
}
/****************************************************************************
Used templates
......
......@@ -45,7 +45,7 @@ class sys_var
struct my_option *option_limits; /* Updated by by set_var_init() */
uint name_length; /* Updated by by set_var_init() */
const char *name;
sys_after_update_func after_update;
bool no_support_one_shot;
sys_var(const char *name_arg)
......@@ -413,7 +413,7 @@ class sys_var_thd_bit :public sys_var_thd
public:
ulong bit_flag;
bool reverse;
sys_var_thd_bit(const char *name_arg,
sys_var_thd_bit(const char *name_arg,
sys_check_func c_func, sys_update_func u_func,
ulong bit, bool reverse_arg=0)
:sys_var_thd(name_arg), check_func(c_func), update_func(u_func),
......@@ -427,6 +427,19 @@ class sys_var_thd_bit :public sys_var_thd
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
class sys_var_thd_dbug :public sys_var_thd
{
public:
sys_var_thd_dbug(const char *name_arg) :sys_var_thd(name_arg) {}
bool check_update_type(Item_result type) { return type != STRING_RESULT; }
bool check(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_CHAR; }
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type) { DBUG_POP(); }
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
};
/* some variables that require special handling */
......
......@@ -2920,7 +2920,7 @@ static int has_temporary_error(THD *thd)
MYSQL_ERROR *err;
while ((err= it++))
{
DBUG_PRINT("info", ("has warning %d %s", err->code, err->msg))
DBUG_PRINT("info", ("has warning %d %s", err->code, err->msg));
switch (err->code)
{
case ER_GET_TEMPORARY_ERRMSG:
......
......@@ -316,13 +316,13 @@ TODO list:
#define MUTEX_UNLOCK(M) {DBUG_PRINT("lock", ("mutex unlock 0x%lx",\
(ulong)(M))); pthread_mutex_unlock(M);}
#define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock 0x%lx",(ulong)(M))); \
if (!rw_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")) \
if (!rw_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
#define RW_RLOCK(M) {DBUG_PRINT("lock", ("rwlock rlock 0x%lx", (ulong)(M))); \
if (!rw_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")) \
if (!rw_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
#define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock 0x%lx",(ulong)(M))); \
if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")) \
if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \
else DBUG_PRINT("lock", ("rwlock unlock FAILED %d", errno)); }
#define STRUCT_LOCK(M) {DBUG_PRINT("lock", ("%d struct lock...",__LINE__)); \
pthread_mutex_lock(M);DBUG_PRINT("lock", ("struct lock OK"));}
......
......@@ -518,7 +518,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
plugin->name.str))
plugin->name.str));
goto err;
}
}
......@@ -531,7 +531,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
sql_print_error("Plugin '%s' handlerton init returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' handlerton init returned error.",
plugin->name.str))
plugin->name.str));
goto err;
}
break;
......@@ -580,7 +580,7 @@ static void plugin_call_deinitializer(void)
if (tmp->plugin->deinit())
{
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
tmp->name.str))
tmp->name.str));
}
}
tmp->state= PLUGIN_IS_UNINITIALIZED;
......
......@@ -23,7 +23,7 @@
*/
#define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \
SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH
SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH
#include <mysql/plugin.h>
#undef SHOW_FUNC
typedef enum enum_mysql_show_type SHOW_TYPE;
......
......@@ -13228,7 +13228,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
for (i= 0; (item= it++); i++)
{
Field *field;
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
item_field= item;
else
......@@ -13247,7 +13247,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
DBUG_RETURN(TRUE); // Fatal error
item_field->name= item->name;
#ifndef DBUG_OFF
if (_db_on_ && !item_field->name)
if (!item_field->name)
{
char buff[256];
String str(buff,sizeof(buff),&my_charset_bin);
......
......@@ -617,7 +617,6 @@ int main(int argc, char *argv[])
static int get_options(int argc,char *argv[])
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -646,7 +645,6 @@ static int get_options(int argc,char *argv[])
printf("Usage: %s [-?ABIKLsWv] [-m#] [-t#]\n",progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
}
......
......@@ -170,7 +170,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'q': silent=1; break;
case 'S': if (stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case 'V':
......
......@@ -284,7 +284,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'N': no_search=1; break;
case 'S': no_stopwords=1; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case 'V':
......
......@@ -208,9 +208,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
if (len != MI_BASE_INFO_SIZE)
{
DBUG_PRINT("warning",("saved_base_info_length: %d base_info_length: %d",
len,MI_BASE_INFO_SIZE))
len,MI_BASE_INFO_SIZE));
}
disk_pos= (char*)
disk_pos= (char*)
my_n_base_info_read((uchar*) disk_cache + base_pos, &share->base);
share->state.state_length=base_pos;
......
......@@ -648,7 +648,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
printf("test1 Ver 1.2 \n");
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case '?':
......
......@@ -864,7 +864,6 @@ reads: %10lu\n",
static void get_options(int argc, char **argv)
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -977,7 +976,6 @@ static void get_options(int argc, char **argv)
progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
default:
......
......@@ -120,7 +120,6 @@ int main(int argc,char **argv)
static void get_options(int argc, char **argv)
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -150,7 +149,6 @@ static void get_options(int argc, char **argv)
printf("Usage: %s [-?lKA] [-f#] [-t#]\n",progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
default:
......
......@@ -281,7 +281,7 @@ GlobalDictCache::drop(NdbTableImpl * tab)
ver.m_refCount--;
ver.m_status = DROPPED;
if(ver.m_refCount == 0){
DBUG_PRINT("info", ("refCount is zero, deleting m_impl"))
DBUG_PRINT("info", ("refCount is zero, deleting m_impl"));
delete ver.m_impl;
vers->erase(i);
}
......
......@@ -978,7 +978,7 @@ void
NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp)
{
DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation");
DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp))
DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp));
// here is one reason to make op lists doubly linked
if (m_firstExecutedScanOp == cursorOp) {
......
......@@ -15187,7 +15187,6 @@ int main(int argc, char **argv)
{
struct my_tests_st *fptr;
DEBUGGER_OFF;
MY_INIT(argv[0]);
load_defaults("my", client_test_load_default_groups, &argc, &argv);
......
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