1/* Copyright (c) 2011, 2015, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16/*
17 Always provide the noop performance interface, for plugins.
18*/
19
20#define USE_PSI_V1
21#define HAVE_PSI_INTERFACE
22
23#include "my_global.h"
24#include "my_pthread.h"
25#include "my_sys.h"
26#include "mysql/psi/psi.h"
27
28C_MODE_START
29
30#define NNN __attribute__((unused))
31
32static void register_mutex_noop(const char *category NNN,
33 PSI_mutex_info *info NNN,
34 int count NNN)
35{
36 return;
37}
38
39static void register_rwlock_noop(const char *category NNN,
40 PSI_rwlock_info *info NNN,
41 int count NNN)
42{
43 return;
44}
45
46static void register_cond_noop(const char *category NNN,
47 PSI_cond_info *info NNN,
48 int count NNN)
49{
50 return;
51}
52
53static void register_thread_noop(const char *category NNN,
54 PSI_thread_info *info NNN,
55 int count NNN)
56{
57 return;
58}
59
60static void register_file_noop(const char *category NNN,
61 PSI_file_info *info NNN,
62 int count NNN)
63{
64 return;
65}
66
67static void register_stage_noop(const char *category NNN,
68 PSI_stage_info **info_array NNN,
69 int count NNN)
70{
71 return;
72}
73
74static void register_statement_noop(const char *category NNN,
75 PSI_statement_info *info NNN,
76 int count NNN)
77{
78 return;
79}
80
81static void register_socket_noop(const char *category NNN,
82 PSI_socket_info *info NNN,
83 int count NNN)
84{
85 return;
86}
87
88static PSI_mutex*
89init_mutex_noop(PSI_mutex_key key NNN, const void *identity NNN)
90{
91 return NULL;
92}
93
94static void destroy_mutex_noop(PSI_mutex* mutex NNN)
95{
96 return;
97}
98
99static PSI_rwlock*
100init_rwlock_noop(PSI_rwlock_key key NNN, const void *identity NNN)
101{
102 return NULL;
103}
104
105static void destroy_rwlock_noop(PSI_rwlock* rwlock NNN)
106{
107 return;
108}
109
110static PSI_cond*
111init_cond_noop(PSI_cond_key key NNN, const void *identity NNN)
112{
113 return NULL;
114}
115
116static void destroy_cond_noop(PSI_cond* cond NNN)
117{
118 return;
119}
120
121static PSI_socket*
122init_socket_noop(PSI_socket_key key NNN, const my_socket *fd NNN,
123 const struct sockaddr *addr NNN, socklen_t addr_len NNN)
124{
125 return NULL;
126}
127
128static void destroy_socket_noop(PSI_socket* socket NNN)
129{
130 return;
131}
132
133static PSI_table_share*
134get_table_share_noop(my_bool temporary NNN, struct TABLE_SHARE *share NNN)
135{
136 return NULL;
137}
138
139static void release_table_share_noop(PSI_table_share* share NNN)
140{
141 return;
142}
143
144static void
145drop_table_share_noop(my_bool temporary NNN, const char *schema_name NNN,
146 int schema_name_length NNN, const char *table_name NNN,
147 int table_name_length NNN)
148{
149 return;
150}
151
152static PSI_table*
153open_table_noop(PSI_table_share *share NNN, const void *identity NNN)
154{
155 return NULL;
156}
157
158static void unbind_table_noop(PSI_table *table NNN)
159{
160 return;
161}
162
163static PSI_table*
164rebind_table_noop(PSI_table_share *share NNN,
165 const void *identity NNN,
166 PSI_table *table NNN)
167{
168 return NULL;
169}
170
171static void close_table_noop(PSI_table *table NNN)
172{
173 return;
174}
175
176static void create_file_noop(PSI_file_key key NNN,
177 const char *name NNN, File file NNN)
178{
179 return;
180}
181
182static int spawn_thread_noop(PSI_thread_key key NNN,
183 pthread_t *thread NNN,
184 const pthread_attr_t *attr NNN,
185 void *(*start_routine)(void*) NNN, void *arg NNN)
186{
187 return pthread_create(thread, attr, start_routine, arg);
188}
189
190static PSI_thread*
191new_thread_noop(PSI_thread_key key NNN,
192 const void *identity NNN, ulonglong thread_id NNN)
193{
194 return NULL;
195}
196
197static void set_thread_id_noop(PSI_thread *thread NNN, ulonglong id NNN)
198{
199 return;
200}
201
202static PSI_thread*
203get_thread_noop(void NNN)
204{
205 return NULL;
206}
207
208static void set_thread_user_noop(const char *user NNN, int user_len NNN)
209{
210 return;
211}
212
213static void set_thread_user_host_noop(const char *user NNN, int user_len NNN,
214 const char *host NNN, int host_len NNN)
215{
216 return;
217}
218
219static void set_thread_db_noop(const char* db NNN, int db_len NNN)
220{
221 return;
222}
223
224static void set_thread_command_noop(int command NNN)
225{
226 return;
227}
228
229static void set_thread_start_time_noop(time_t start_time NNN)
230{
231 return;
232}
233
234static void set_thread_state_noop(const char* state NNN)
235{
236 return;
237}
238
239static void set_thread_info_noop(const char* info NNN, uint info_len NNN)
240{
241 return;
242}
243
244static void set_thread_noop(PSI_thread* thread NNN)
245{
246 return;
247}
248
249static void delete_current_thread_noop(void)
250{
251 return;
252}
253
254static void delete_thread_noop(PSI_thread *thread NNN)
255{
256 return;
257}
258
259static PSI_file_locker*
260get_thread_file_name_locker_noop(PSI_file_locker_state *state NNN,
261 PSI_file_key key NNN,
262 enum PSI_file_operation op NNN,
263 const char *name NNN, const void *identity NNN)
264{
265 return NULL;
266}
267
268static PSI_file_locker*
269get_thread_file_stream_locker_noop(PSI_file_locker_state *state NNN,
270 PSI_file *file NNN,
271 enum PSI_file_operation op NNN)
272{
273 return NULL;
274}
275
276
277static PSI_file_locker*
278get_thread_file_descriptor_locker_noop(PSI_file_locker_state *state NNN,
279 File file NNN,
280 enum PSI_file_operation op NNN)
281{
282 return NULL;
283}
284
285static void unlock_mutex_noop(PSI_mutex *mutex NNN)
286{
287 return;
288}
289
290static void unlock_rwlock_noop(PSI_rwlock *rwlock NNN)
291{
292 return;
293}
294
295static void signal_cond_noop(PSI_cond* cond NNN)
296{
297 return;
298}
299
300static void broadcast_cond_noop(PSI_cond* cond NNN)
301{
302 return;
303}
304
305static PSI_idle_locker*
306start_idle_wait_noop(PSI_idle_locker_state* state NNN,
307 const char *src_file NNN, uint src_line NNN)
308{
309 return NULL;
310}
311
312static void end_idle_wait_noop(PSI_idle_locker* locker NNN)
313{
314 return;
315}
316
317static PSI_mutex_locker*
318start_mutex_wait_noop(PSI_mutex_locker_state *state NNN,
319 PSI_mutex *mutex NNN,
320 PSI_mutex_operation op NNN,
321 const char *src_file NNN, uint src_line NNN)
322{
323 return NULL;
324}
325
326static void end_mutex_wait_noop(PSI_mutex_locker* locker NNN, int rc NNN)
327{
328 return;
329}
330
331
332static PSI_rwlock_locker*
333start_rwlock_rdwait_noop(struct PSI_rwlock_locker_state_v1 *state NNN,
334 struct PSI_rwlock *rwlock NNN,
335 enum PSI_rwlock_operation op NNN,
336 const char *src_file NNN, uint src_line NNN)
337{
338 return NULL;
339}
340
341static void end_rwlock_rdwait_noop(PSI_rwlock_locker* locker NNN, int rc NNN)
342{
343 return;
344}
345
346static struct PSI_rwlock_locker*
347start_rwlock_wrwait_noop(struct PSI_rwlock_locker_state_v1 *state NNN,
348 struct PSI_rwlock *rwlock NNN,
349 enum PSI_rwlock_operation op NNN,
350 const char *src_file NNN, uint src_line NNN)
351{
352 return NULL;
353}
354
355static void end_rwlock_wrwait_noop(PSI_rwlock_locker* locker NNN, int rc NNN)
356{
357 return;
358}
359
360static struct PSI_cond_locker*
361start_cond_wait_noop(struct PSI_cond_locker_state_v1 *state NNN,
362 struct PSI_cond *cond NNN,
363 struct PSI_mutex *mutex NNN,
364 enum PSI_cond_operation op NNN,
365 const char *src_file NNN, uint src_line NNN)
366{
367 return NULL;
368}
369
370static void end_cond_wait_noop(PSI_cond_locker* locker NNN, int rc NNN)
371{
372 return;
373}
374
375static struct PSI_table_locker*
376start_table_io_wait_noop(struct PSI_table_locker_state_v1 *state NNN,
377 struct PSI_table *table NNN,
378 enum PSI_table_io_operation op NNN,
379 uint index NNN,
380 const char *src_file NNN, uint src_line NNN)
381{
382 return NULL;
383}
384
385static void end_table_io_wait_noop(PSI_table_locker* locker NNN)
386{
387 return;
388}
389
390static struct PSI_table_locker*
391start_table_lock_wait_noop(struct PSI_table_locker_state_v1 *state NNN,
392 struct PSI_table *table NNN,
393 enum PSI_table_lock_operation op NNN,
394 ulong flags NNN,
395 const char *src_file NNN, uint src_line NNN)
396{
397 return NULL;
398}
399
400static void end_table_lock_wait_noop(PSI_table_locker* locker NNN)
401{
402 return;
403}
404
405static void start_file_open_wait_noop(PSI_file_locker *locker NNN,
406 const char *src_file NNN,
407 uint src_line NNN)
408{
409 return;
410}
411
412static PSI_file* end_file_open_wait_noop(PSI_file_locker *locker NNN,
413 void *result NNN)
414{
415 return NULL;
416}
417
418static void end_file_open_wait_and_bind_to_descriptor_noop
419 (PSI_file_locker *locker NNN, File file NNN)
420{
421 return;
422}
423
424static void start_file_wait_noop(PSI_file_locker *locker NNN,
425 size_t count NNN,
426 const char *src_file NNN,
427 uint src_line NNN)
428{
429 return;
430}
431
432static void end_file_wait_noop(PSI_file_locker *locker NNN,
433 size_t count NNN)
434{
435 return;
436}
437
438static void start_file_close_wait_noop(PSI_file_locker *locker NNN,
439 const char *src_file NNN,
440 uint src_line NNN)
441{
442 return;
443}
444
445static void end_file_close_wait_noop(PSI_file_locker *locker NNN,
446 int result NNN)
447{
448 return;
449}
450
451static void start_stage_noop(PSI_stage_key key NNN,
452 const char *src_file NNN, int src_line NNN)
453{
454 return;
455}
456
457static void end_stage_noop(void)
458{
459 return;
460}
461
462static PSI_statement_locker*
463get_thread_statement_locker_noop(PSI_statement_locker_state *state NNN,
464 PSI_statement_key key NNN,
465 const void *charset NNN)
466{
467 return NULL;
468}
469
470static PSI_statement_locker*
471refine_statement_noop(PSI_statement_locker *locker NNN,
472 PSI_statement_key key NNN)
473{
474 return NULL;
475}
476
477static void start_statement_noop(PSI_statement_locker *locker NNN,
478 const char *db NNN, uint db_len NNN,
479 const char *src_file NNN, uint src_line NNN)
480{
481 return;
482}
483
484static void set_statement_text_noop(PSI_statement_locker *locker NNN,
485 const char *text NNN, uint text_len NNN)
486{
487 return;
488}
489
490static void set_statement_lock_time_noop(PSI_statement_locker *locker NNN,
491 ulonglong count NNN)
492{
493 return;
494}
495
496static void set_statement_rows_sent_noop(PSI_statement_locker *locker NNN,
497 ulonglong count NNN)
498{
499 return;
500}
501
502static void set_statement_rows_examined_noop(PSI_statement_locker *locker NNN,
503 ulonglong count NNN)
504{
505 return;
506}
507
508static void inc_statement_created_tmp_disk_tables_noop(PSI_statement_locker *locker NNN,
509 ulong count NNN)
510{
511 return;
512}
513
514static void inc_statement_created_tmp_tables_noop(PSI_statement_locker *locker NNN,
515 ulong count NNN)
516{
517 return;
518}
519
520static void inc_statement_select_full_join_noop(PSI_statement_locker *locker NNN,
521 ulong count NNN)
522{
523 return;
524}
525
526static void inc_statement_select_full_range_join_noop(PSI_statement_locker *locker NNN,
527 ulong count NNN)
528{
529 return;
530}
531
532static void inc_statement_select_range_noop(PSI_statement_locker *locker NNN,
533 ulong count NNN)
534{
535 return;
536}
537
538static void inc_statement_select_range_check_noop(PSI_statement_locker *locker NNN,
539 ulong count NNN)
540{
541 return;
542}
543
544static void inc_statement_select_scan_noop(PSI_statement_locker *locker NNN,
545 ulong count NNN)
546{
547 return;
548}
549
550static void inc_statement_sort_merge_passes_noop(PSI_statement_locker *locker NNN,
551 ulong count NNN)
552{
553 return;
554}
555
556static void inc_statement_sort_range_noop(PSI_statement_locker *locker NNN,
557 ulong count NNN)
558{
559 return;
560}
561
562static void inc_statement_sort_rows_noop(PSI_statement_locker *locker NNN,
563 ulong count NNN)
564{
565 return;
566}
567
568static void inc_statement_sort_scan_noop(PSI_statement_locker *locker NNN,
569 ulong count NNN)
570{
571 return;
572}
573
574static void set_statement_no_index_used_noop(PSI_statement_locker *locker NNN)
575{
576 return;
577}
578
579static void set_statement_no_good_index_used_noop(PSI_statement_locker *locker NNN)
580{
581 return;
582}
583
584static void end_statement_noop(PSI_statement_locker *locker NNN,
585 void *stmt_da NNN)
586{
587 return;
588}
589
590static PSI_socket_locker*
591start_socket_wait_noop(PSI_socket_locker_state *state NNN,
592 PSI_socket *socket NNN,
593 PSI_socket_operation op NNN,
594 size_t count NNN,
595 const char *src_file NNN,
596 uint src_line NNN)
597{
598 return NULL;
599}
600
601static void end_socket_wait_noop(PSI_socket_locker *locker NNN,
602 size_t count NNN)
603{
604 return;
605}
606
607static void set_socket_state_noop(PSI_socket *socket NNN,
608 enum PSI_socket_state state NNN)
609{
610 return;
611}
612
613static void set_socket_info_noop(PSI_socket *socket NNN,
614 const my_socket *fd NNN,
615 const struct sockaddr *addr NNN,
616 socklen_t addr_len NNN)
617{
618 return;
619}
620
621static void set_socket_thread_owner_noop(PSI_socket *socket NNN)
622{
623 return;
624}
625
626static struct PSI_digest_locker*
627digest_start_noop(PSI_statement_locker *locker NNN)
628{
629 return NULL;
630}
631
632static void
633digest_end_noop(PSI_digest_locker *locker NNN,
634 const struct sql_digest_storage *digest NNN)
635{
636 return;
637}
638
639static int
640set_thread_connect_attrs_noop(const char *buffer NNN,
641 uint length NNN,
642 const void *from_cs NNN)
643{
644 return 0;
645}
646
647static PSI PSI_noop=
648{
649 register_mutex_noop,
650 register_rwlock_noop,
651 register_cond_noop,
652 register_thread_noop,
653 register_file_noop,
654 register_stage_noop,
655 register_statement_noop,
656 register_socket_noop,
657 init_mutex_noop,
658 destroy_mutex_noop,
659 init_rwlock_noop,
660 destroy_rwlock_noop,
661 init_cond_noop,
662 destroy_cond_noop,
663 init_socket_noop,
664 destroy_socket_noop,
665 get_table_share_noop,
666 release_table_share_noop,
667 drop_table_share_noop,
668 open_table_noop,
669 unbind_table_noop,
670 rebind_table_noop,
671 close_table_noop,
672 create_file_noop,
673 spawn_thread_noop,
674 new_thread_noop,
675 set_thread_id_noop,
676 get_thread_noop,
677 set_thread_user_noop,
678 set_thread_user_host_noop,
679 set_thread_db_noop,
680 set_thread_command_noop,
681 set_thread_start_time_noop,
682 set_thread_state_noop,
683 set_thread_info_noop,
684 set_thread_noop,
685 delete_current_thread_noop,
686 delete_thread_noop,
687 get_thread_file_name_locker_noop,
688 get_thread_file_stream_locker_noop,
689 get_thread_file_descriptor_locker_noop,
690 unlock_mutex_noop,
691 unlock_rwlock_noop,
692 signal_cond_noop,
693 broadcast_cond_noop,
694 start_idle_wait_noop,
695 end_idle_wait_noop,
696 start_mutex_wait_noop,
697 end_mutex_wait_noop,
698 start_rwlock_rdwait_noop,
699 end_rwlock_rdwait_noop,
700 start_rwlock_wrwait_noop,
701 end_rwlock_wrwait_noop,
702 start_cond_wait_noop,
703 end_cond_wait_noop,
704 start_table_io_wait_noop,
705 end_table_io_wait_noop,
706 start_table_lock_wait_noop,
707 end_table_lock_wait_noop,
708 start_file_open_wait_noop,
709 end_file_open_wait_noop,
710 end_file_open_wait_and_bind_to_descriptor_noop,
711 start_file_wait_noop,
712 end_file_wait_noop,
713 start_file_close_wait_noop,
714 end_file_close_wait_noop,
715 start_stage_noop,
716 end_stage_noop,
717 get_thread_statement_locker_noop,
718 refine_statement_noop,
719 start_statement_noop,
720 set_statement_text_noop,
721 set_statement_lock_time_noop,
722 set_statement_rows_sent_noop,
723 set_statement_rows_examined_noop,
724 inc_statement_created_tmp_disk_tables_noop,
725 inc_statement_created_tmp_tables_noop,
726 inc_statement_select_full_join_noop,
727 inc_statement_select_full_range_join_noop,
728 inc_statement_select_range_noop,
729 inc_statement_select_range_check_noop,
730 inc_statement_select_scan_noop,
731 inc_statement_sort_merge_passes_noop,
732 inc_statement_sort_range_noop,
733 inc_statement_sort_rows_noop,
734 inc_statement_sort_scan_noop,
735 set_statement_no_index_used_noop,
736 set_statement_no_good_index_used_noop,
737 end_statement_noop,
738 start_socket_wait_noop,
739 end_socket_wait_noop,
740 set_socket_state_noop,
741 set_socket_info_noop,
742 set_socket_thread_owner_noop,
743 digest_start_noop,
744 digest_end_noop,
745 set_thread_connect_attrs_noop
746};
747
748/**
749 Hook for the instrumentation interface.
750 Code implementing the instrumentation interface should register here.
751*/
752struct PSI_bootstrap *PSI_hook= NULL;
753
754/**
755 Instance of the instrumentation interface for the MySQL server.
756 @todo This is currently a global variable, which is handy when
757 compiling instrumented code that is bundled with the server.
758 When dynamic plugin are truly supported, this variable will need
759 to be replaced by a macro, so that each XYZ plugin can have it's own
760 xyz_psi_server variable, obtained from PSI_bootstrap::get_interface()
761 with the version used at compile time for plugin XYZ.
762*/
763
764PSI *PSI_server= & PSI_noop;
765
766/**
767 Global performance schema flag.
768 Indicate if the performance schema is enabled.
769 This flag is set at startup, and never changes.
770*/
771my_bool pfs_enabled= FALSE;
772
773void set_psi_server(PSI *psi)
774{
775 PSI_server= psi;
776}
777
778C_MODE_END
779