Skip to content

Commit e33a8b2

Browse files
author
Marc Alff
committed
WL#2360 Performance schema
Part III: mysys instrumentation
1 parent fd433cf commit e33a8b2

Some content is hidden

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

64 files changed

+1380
-916
lines changed

client/client_priv.h

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2001-2006 MySQL AB
1+
/* Copyright (C) 2001-2006 MySQL AB, 2009 Sun Microsystems, Inc
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -87,3 +87,24 @@ enum options_client
8787
OPT_INIT_COMMAND,
8888
OPT_MAX_CLIENT_OPTION
8989
};
90+
91+
/**
92+
First mysql version supporting the information schema.
93+
*/
94+
#define FIRST_INFORMATION_SCHEMA_VERSION 50003
95+
96+
/**
97+
Name of the information schema database.
98+
*/
99+
#define INFORMATION_SCHEMA_DB_NAME "information_schema"
100+
101+
/**
102+
First mysql version supporting the performance schema.
103+
*/
104+
#define FIRST_PERFORMANCE_SCHEMA_VERSION 50600
105+
106+
/**
107+
Name of the performance schema database.
108+
*/
109+
#define PERFORMANCE_SCHEMA_DB_NAME "performance_schema"
110+

client/mysqlcheck.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2000 MySQL AB
1+
/* Copyright (C) 2000 MySQL AB, 2009 Sun Microsystems, Inc
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -644,8 +644,11 @@ static int process_one_db(char *database)
644644

645645
static int use_db(char *database)
646646
{
647-
if (mysql_get_server_version(sock) >= 50003 &&
648-
!my_strcasecmp(&my_charset_latin1, database, "information_schema"))
647+
if (mysql_get_server_version(sock) >= FIRST_INFORMATION_SCHEMA_VERSION &&
648+
!my_strcasecmp(&my_charset_latin1, database, INFORMATION_SCHEMA_DB_NAME))
649+
return 1;
650+
if (mysql_get_server_version(sock) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
651+
!my_strcasecmp(&my_charset_latin1, database, PERFORMANCE_SCHEMA_DB_NAME))
649652
return 1;
650653
if (mysql_select_db(sock, database))
651654
{

client/mysqldump.c

+17-7
Original file line numberDiff line numberDiff line change
@@ -3836,8 +3836,12 @@ static int dump_all_databases()
38363836
return 1;
38373837
while ((row= mysql_fetch_row(tableres)))
38383838
{
3839-
if (mysql_get_server_version(mysql) >= 50003 &&
3840-
!my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
3839+
if (mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
3840+
!my_strcasecmp(&my_charset_latin1, row[0], INFORMATION_SCHEMA_DB_NAME))
3841+
continue;
3842+
3843+
if (mysql_get_server_version(mysql) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
3844+
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
38413845
continue;
38423846

38433847
if (dump_all_tables_in_db(row[0]))
@@ -3854,8 +3858,12 @@ static int dump_all_databases()
38543858
}
38553859
while ((row= mysql_fetch_row(tableres)))
38563860
{
3857-
if (mysql_get_server_version(mysql) >= 50003 &&
3858-
!my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
3861+
if (mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
3862+
!my_strcasecmp(&my_charset_latin1, row[0], INFORMATION_SCHEMA_DB_NAME))
3863+
continue;
3864+
3865+
if (mysql_get_server_version(mysql) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
3866+
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
38593867
continue;
38603868

38613869
if (dump_all_views_in_db(row[0]))
@@ -4256,10 +4264,12 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
42564264
}
42574265
end= pos;
42584266

4259-
/* Can't LOCK TABLES in INFORMATION_SCHEMA, so don't try. */
4267+
/* Can't LOCK TABLES in I_S / P_S, so don't try. */
42604268
if (lock_tables &&
4261-
!(mysql_get_server_version(mysql) >= 50003 &&
4262-
!my_strcasecmp(&my_charset_latin1, db, "information_schema")))
4269+
!(mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
4270+
!my_strcasecmp(&my_charset_latin1, db, INFORMATION_SCHEMA_DB_NAME)) &&
4271+
!(mysql_get_server_version(mysql) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
4272+
!my_strcasecmp(&my_charset_latin1, db, PERFORMANCE_SCHEMA_DB_NAME)))
42634273
{
42644274
if (mysql_real_query(mysql, lock_tables_query.str,
42654275
lock_tables_query.length-1))

include/keycache.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2003 MySQL AB
1+
/* Copyright (C) 2003 MySQL AB, 2009 Sun Microsystems, Inc
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -70,7 +70,7 @@ typedef struct st_key_cache
7070
uchar HUGE_PTR *block_mem; /* memory for block buffers */
7171
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
7272
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
73-
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
73+
mysql_mutex_t cache_lock; /* to lock access to the cache structure */
7474
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
7575
/*
7676
Waiting for a zero resize count. Using a queue for symmetry though

include/my_bitmap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2000 MySQL AB
1+
/* Copyright (C) 2000 MySQL AB, 2009 Sun Microsystems, Inc
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ typedef struct st_bitmap
3434
acquiring the mutex
3535
*/
3636
#ifdef THREAD
37-
pthread_mutex_t *mutex;
37+
mysql_mutex_t *mutex;
3838
#endif
3939
} MY_BITMAP;
4040

include/my_pthread.h

+10-8
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr;
607607
typedef ulong my_thread_id;
608608

609609
extern my_bool my_thread_global_init(void);
610+
extern my_bool my_thread_basic_global_init(void);
611+
extern void my_thread_basic_global_reinit(void);
610612
extern void my_thread_global_end(void);
611613
extern my_bool my_thread_init(void);
612614
extern void my_thread_end(void);
@@ -637,10 +639,10 @@ extern int pthread_dummy(int);
637639
struct st_my_thread_var
638640
{
639641
int thr_errno;
640-
pthread_cond_t suspend;
641-
pthread_mutex_t mutex;
642-
pthread_mutex_t * volatile current_mutex;
643-
pthread_cond_t * volatile current_cond;
642+
mysql_cond_t suspend;
643+
mysql_mutex_t mutex;
644+
mysql_mutex_t * volatile current_mutex;
645+
mysql_cond_t * volatile current_cond;
644646
pthread_t pthread_self;
645647
my_thread_id id;
646648
int cmp_length;
@@ -692,16 +694,16 @@ extern uint thd_lib_detected;
692694
#ifdef THREAD
693695
#ifndef thread_safe_increment
694696
#define thread_safe_increment(V,L) \
695-
(pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
697+
(mysql_mutex_lock((L)), (V)++, mysql_mutex_unlock((L)))
696698
#define thread_safe_decrement(V,L) \
697-
(pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
699+
(mysql_mutex_lock((L)), (V)--, mysql_mutex_unlock((L)))
698700
#endif
699701

700702
#ifndef thread_safe_add
701703
#define thread_safe_add(V,C,L) \
702-
(pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
704+
(mysql_mutex_lock((L)), (V)+=(C), mysql_mutex_unlock((L)))
703705
#define thread_safe_sub(V,C,L) \
704-
(pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
706+
(mysql_mutex_lock((L)), (V)-=(C), mysql_mutex_unlock((L)))
705707
#endif
706708
#endif
707709

include/my_sys.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ struct st_my_file_info
338338
#endif
339339
enum file_type type;
340340
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
341-
pthread_mutex_t mutex;
341+
mysql_mutex_t mutex;
342342
#endif
343343
};
344344

@@ -358,7 +358,7 @@ typedef struct st_my_tmpdir
358358
char **list;
359359
uint cur, max;
360360
#ifdef THREAD
361-
pthread_mutex_t mutex;
361+
mysql_mutex_t mutex;
362362
#endif
363363
} MY_TMPDIR;
364364

@@ -374,9 +374,9 @@ typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
374374
#ifdef THREAD
375375
typedef struct st_io_cache_share
376376
{
377-
pthread_mutex_t mutex; /* To sync on reads into buffer. */
378-
pthread_cond_t cond; /* To wait for signals. */
379-
pthread_cond_t cond_writer; /* For a synchronized writer. */
377+
mysql_mutex_t mutex; /* To sync on reads into buffer. */
378+
mysql_cond_t cond; /* To wait for signals. */
379+
mysql_cond_t cond_writer; /* For a synchronized writer. */
380380
/* Offset in file corresponding to the first byte of buffer. */
381381
my_off_t pos_in_file;
382382
/* If a synchronized write cache is the source of the data. */
@@ -437,7 +437,7 @@ typedef struct st_io_cache /* Used when cacheing files */
437437
The lock is for append buffer used in SEQ_READ_APPEND cache
438438
need mutex copying from append buffer to read buffer.
439439
*/
440-
pthread_mutex_t append_buffer_lock;
440+
mysql_mutex_t append_buffer_lock;
441441
/*
442442
The following is used when several threads are reading the
443443
same file in parallel. They are synchronized on disk
@@ -691,6 +691,7 @@ extern const char **my_error_unregister(int first, int last);
691691
extern void my_message(uint my_err, const char *str,myf MyFlags);
692692
extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
693693
extern void my_message_curses(uint my_err, const char *str,myf MyFlags);
694+
extern my_bool my_basic_init(void);
694695
extern my_bool my_init(void);
695696
extern void my_end(int infoflag);
696697
extern int my_redel(const char *from, const char *to, int MyFlags);

include/thr_lock.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
1+
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -115,10 +115,11 @@ typedef struct st_thr_lock_data {
115115
THR_LOCK_OWNER *owner;
116116
struct st_thr_lock_data *next,**prev;
117117
struct st_thr_lock *lock;
118-
pthread_cond_t *cond;
118+
mysql_cond_t *cond;
119119
enum thr_lock_type type;
120120
void *status_param; /* Param to status functions */
121121
void *debug_print_param;
122+
struct PSI_table *m_psi;
122123
} THR_LOCK_DATA;
123124

124125
struct st_lock_list {
@@ -127,7 +128,7 @@ struct st_lock_list {
127128

128129
typedef struct st_thr_lock {
129130
LIST list;
130-
pthread_mutex_t mutex;
131+
mysql_mutex_t mutex;
131132
struct st_lock_list read_wait;
132133
struct st_lock_list read;
133134
struct st_lock_list write_wait;
@@ -144,7 +145,7 @@ typedef struct st_thr_lock {
144145

145146

146147
extern LIST *thr_lock_thread_list;
147-
extern pthread_mutex_t THR_LOCK_lock;
148+
extern mysql_mutex_t THR_LOCK_lock;
148149

149150
my_bool init_thr_lock(void); /* Must be called once/thread */
150151
#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)

mysys/charset.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2000 MySQL AB
1+
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -339,10 +339,10 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
339339
!(buf= (uchar*) my_malloc(len,myflags)))
340340
return TRUE;
341341

342-
if ((fd=my_open(filename,O_RDONLY,myflags)) < 0)
342+
if ((fd= mysql_file_open(key_file_charset, filename, O_RDONLY, myflags)) < 0)
343343
goto error;
344-
tmp_len=my_read(fd, buf, len, myflags);
345-
my_close(fd,myflags);
344+
tmp_len= mysql_file_read(fd, buf, len, myflags);
345+
mysql_file_close(fd, myflags);
346346
if (tmp_len != len)
347347
goto error;
348348

@@ -421,7 +421,7 @@ static my_bool init_available_charsets(myf myflags)
421421
To make things thread safe we are not allowing other threads to interfere
422422
while we may changing the cs_info_table
423423
*/
424-
pthread_mutex_lock(&THR_LOCK_charset);
424+
mysql_mutex_lock(&THR_LOCK_charset);
425425
if (!charset_initialized)
426426
{
427427
bzero(&all_charsets,sizeof(all_charsets));
@@ -444,7 +444,7 @@ static my_bool init_available_charsets(myf myflags)
444444
error= my_read_charset_file(fname,myflags);
445445
charset_initialized=1;
446446
}
447-
pthread_mutex_unlock(&THR_LOCK_charset);
447+
mysql_mutex_unlock(&THR_LOCK_charset);
448448
}
449449
return error;
450450
}
@@ -507,7 +507,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
507507
To make things thread safe we are not allowing other threads to interfere
508508
while we may changing the cs_info_table
509509
*/
510-
pthread_mutex_lock(&THR_LOCK_charset);
510+
mysql_mutex_lock(&THR_LOCK_charset);
511511

512512
if (!(cs->state & (MY_CS_COMPILED|MY_CS_LOADED))) /* if CS is not in memory */
513513
{
@@ -529,7 +529,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
529529
else
530530
cs= NULL;
531531

532-
pthread_mutex_unlock(&THR_LOCK_charset);
532+
mysql_mutex_unlock(&THR_LOCK_charset);
533533
}
534534
return cs;
535535
}

mysys/default.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2000-2003 MySQL AB
1+
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -683,7 +683,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
683683
static const char includedir_keyword[]= "includedir";
684684
static const char include_keyword[]= "include";
685685
const int max_recursion_level= 10;
686-
FILE *fp;
686+
MYSQL_FILE *fp;
687687
uint line=0;
688688
my_bool found_group=0;
689689
uint i;
@@ -723,10 +723,10 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
723723
}
724724
}
725725
#endif
726-
if (!(fp= my_fopen(name, O_RDONLY, MYF(0))))
726+
if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
727727
return 1; /* Ignore wrong files */
728728

729-
while (fgets(buff, sizeof(buff) - 1, fp))
729+
while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
730730
{
731731
line++;
732732
/* Ignore comment and empty lines */
@@ -916,11 +916,11 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
916916
goto err;
917917
}
918918
}
919-
my_fclose(fp,MYF(0));
919+
mysql_file_fclose(fp, MYF(0));
920920
return(0);
921921

922922
err:
923-
my_fclose(fp,MYF(0));
923+
mysql_file_fclose(fp, MYF(0));
924924
return -1; /* Fatal error */
925925
}
926926

0 commit comments

Comments
 (0)