Skip to content

Commit b16289a

Browse files
author
[email protected]/nosik.monty.fi
committed
Slow query log to file now displays queries with microsecond precission
--long-query-time is now given in seconds with microseconds as decimals --min_examined_row_limit added for slow query log long_query_time user variable is now double with 6 decimals Added functions to get time in microseconds Added faster time() functions for system that has gethrtime() (Solaris) We now do less time() calls. Added field->in_read_set() and field->in_write_set() for easier field manipulation by handlers set_var.cc and my_getopt() can now handle DOUBLE variables. All time() calls changed to my_time() my_time() now does retry's if time() call fails. Added debug function for stopping in mysql_admin_table() when tables are locked Some trivial function and struct variable renames to avoid merge errors. Fixed compiler warnings Initialization of some time variables on windows moved to my_init()
1 parent a33c863 commit b16289a

56 files changed

Lines changed: 625 additions & 245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/my_getopt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ C_MODE_START
3131
#define GET_DISABLED 11
3232
#define GET_ENUM 12
3333
#define GET_SET 13
34+
#define GET_DOUBLE 14
3435

3536
#define GET_ASK_ADDR 128
3637
#define GET_TYPE_MASK 127

include/my_sys.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ extern my_bool my_compress(uchar *, size_t *, size_t *);
833833
extern my_bool my_uncompress(uchar *, size_t , size_t *);
834834
extern uchar *my_compress_alloc(const uchar *packet, size_t *len,
835835
size_t *complen);
836-
extern int packfrm(const uchar *, size_t, uchar **, size_t *);
836+
extern int packfrm(uchar *, size_t, uchar **, size_t *);
837837
extern int unpackfrm(uchar **, size_t *, const uchar *);
838838

839839
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
@@ -846,7 +846,11 @@ extern void my_sleep(ulong m_seconds);
846846
extern uint my_set_max_open_files(uint files);
847847
void my_free_open_file_info(void);
848848

849+
extern time_t my_time(myf flags);
849850
extern ulonglong my_getsystime(void);
851+
extern ulonglong my_micro_time();
852+
extern ulonglong my_micro_time_and_time(time_t *time_arg);
853+
time_t my_time_possible_from_micro(ulonglong microtime);
850854
extern my_bool my_gethwaddr(uchar *to);
851855
extern int my_getncpus();
852856

include/mysql/plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ enum enum_mysql_show_type
110110
{
111111
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
112112
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
113-
SHOW_ARRAY, SHOW_FUNC
113+
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
114114
};
115115

116116
struct st_mysql_show_var {

libmysql/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ADD_LIBRARY(libmysql SHARED dll.c libmysql.def
6363
../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
6464
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
6565
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
66-
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c)
66+
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/my_getsystime.c)
6767
ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt)
6868
TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32)
6969

libmysql/Makefile.shared

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
6868
mf_iocache2.lo my_seek.lo my_sleep.lo \
6969
my_pread.lo mf_cache.lo md5.lo sha1.lo \
7070
my_getopt.lo my_gethostbyname.lo my_port.lo \
71-
my_rename.lo my_chsize.lo
71+
my_rename.lo my_chsize.lo my_getsystime.lo
7272
sqlobjects = net.lo
7373
sql_cmn_objects = pack.lo client.lo my_time.lo
7474

mysql-test/r/variables.result

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,14 @@ set interactive_timeout=100;
444444
set join_buffer_size=100;
445445
set last_insert_id=1;
446446
set global local_infile=1;
447-
set long_query_time=100;
447+
set long_query_time=0.000001;
448+
select @@long_query_time;
449+
@@long_query_time
450+
0.000001
451+
set long_query_time=100.000001;
452+
select @@long_query_time;
453+
@@long_query_time
454+
100.000001
448455
set low_priority_updates=1;
449456
set max_allowed_packet=100;
450457
set global max_binlog_cache_size=100;

mysql-test/t/variables.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ set interactive_timeout=100;
268268
set join_buffer_size=100;
269269
set last_insert_id=1;
270270
set global local_infile=1;
271-
set long_query_time=100;
271+
set long_query_time=0.000001;
272+
select @@long_query_time;
273+
set long_query_time=100.000001;
274+
select @@long_query_time;
272275
set low_priority_updates=1;
273276
set max_allowed_packet=100;
274277
set global max_binlog_cache_size=100;

mysys/charset.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,14 @@ static int charset_initialized=0;
323323

324324
static my_bool my_read_charset_file(const char *filename, myf myflags)
325325
{
326-
char *buf;
326+
uchar *buf;
327327
int fd;
328328
uint len, tmp_len;
329329
MY_STAT stat_info;
330330

331331
if (!my_stat(filename, &stat_info, MYF(myflags)) ||
332332
((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) ||
333-
!(buf= (char *)my_malloc(len,myflags)))
333+
!(buf= (uchar*) my_malloc(len,myflags)))
334334
return TRUE;
335335

336336
if ((fd=my_open(filename,O_RDONLY,myflags)) < 0)
@@ -340,7 +340,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
340340
if (tmp_len != len)
341341
goto error;
342342

343-
if (my_parse_charset_xml(buf,len,add_collation))
343+
if (my_parse_charset_xml((char*) buf,len,add_collation))
344344
{
345345
#ifdef NOT_YET
346346
printf("ERROR at line %d pos %d '%s'\n",
@@ -350,7 +350,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
350350
#endif
351351
}
352352

353-
my_free(buf, myflags);
353+
my_free(buf, myflags);
354354
return FALSE;
355355

356356
error:

mysys/default_modify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ int modify_defaults_file(const char *file_location, const char *option,
218218
if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0,
219219
MYF(MY_WME)) ||
220220
my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
221-
my_fwrite(cnf_file, file_buffer, (size_t) (dst_ptr - file_buffer),
221+
my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer),
222222
MYF(MY_NABP)))
223223
goto err;
224224
}

mysys/hash.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void my_hash_reset(HASH *hash)
137137
DBUG_VOID_RETURN;
138138
}
139139

140-
/* some helper functions */
140+
/* some helper functions */
141141

142142
/*
143143
This function is char* instead of uchar* as HPUX11 compiler can't
@@ -149,9 +149,9 @@ hash_key(const HASH *hash, const uchar *record, size_t *length,
149149
my_bool first)
150150
{
151151
if (hash->get_key)
152-
return (*hash->get_key)(record,length,first);
152+
return (char*) (*hash->get_key)(record,length,first);
153153
*length=hash->key_length;
154-
return (uchar*) record+hash->key_offset;
154+
return (char*) record+hash->key_offset;
155155
}
156156

157157
/* Calculate pos according to keys */
@@ -313,12 +313,14 @@ my_bool my_hash_insert(HASH *info,const uchar *record)
313313
uchar *ptr_to_rec,*ptr_to_rec2;
314314
HASH_LINK *data,*empty,*gpos,*gpos2,*pos;
315315

316-
LINT_INIT(gpos); LINT_INIT(gpos2);
317-
LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2);
316+
LINT_INIT(gpos);
317+
LINT_INIT(gpos2);
318+
LINT_INIT(ptr_to_rec);
319+
LINT_INIT(ptr_to_rec2);
318320

319321
if (HASH_UNIQUE & info->flags)
320322
{
321-
char *key= (char*) hash_key(info, record, &idx, 1);
323+
uchar *key= (uchar*) hash_key(info, record, &idx, 1);
322324
if (hash_search(info, key, idx))
323325
return(TRUE); /* Duplicate entry */
324326
}
@@ -544,14 +546,16 @@ my_bool hash_update(HASH *hash, uchar *record, uchar *old_key,
544546
if (HASH_UNIQUE & hash->flags)
545547
{
546548
HASH_SEARCH_STATE state;
547-
char *found, *new_key= hash_key(hash, record, &idx, 1);
549+
uchar *found, *new_key= (uchar*) hash_key(hash, record, &idx, 1);
548550
if ((found= hash_first(hash, new_key, idx, &state)))
551+
{
549552
do
550553
{
551-
if (found != (char*) record)
554+
if (found != record)
552555
DBUG_RETURN(1); /* Duplicate entry */
553556
}
554557
while ((found= hash_next(hash, new_key, idx, &state)));
558+
}
555559
}
556560

557561
data=dynamic_element(&hash->array,0,HASH_LINK*);

0 commit comments

Comments
 (0)