1 /* Copyright (c) 2008, 2021, 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, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software Foundation, 21 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 23 #ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H 24 #define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H 25 26 #ifdef EMBEDDED_LIBRARY 27 #define DISABLE_ALL_PSI 28 #endif /* EMBEDDED_LIBRARY */ 29 30 #ifndef MY_GLOBAL_INCLUDED 31 /* 32 Make sure a .c or .cc file contains an include to my_global.h first. 33 When this include is missing, all the #ifdef HAVE_XXX have no effect, 34 and the resulting binary won't build, or won't link, 35 or will crash at runtime 36 since various structures will have different binary definitions. 37 */ 38 #error "You must include my_global.h in the code for the build to be correct." 39 #endif 40 41 #include "psi_base.h" 42 #include "psi_memory.h" 43 44 /* 45 MAINTAINER: 46 The following pattern: 47 typedef struct XYZ XYZ; 48 is not needed in C++, but required for C. 49 */ 50 51 C_MODE_START 52 53 /** @sa MDL_key. */ 54 struct MDL_key; 55 typedef struct MDL_key MDL_key; 56 57 /** @sa enum_mdl_type. */ 58 typedef int opaque_mdl_type; 59 60 /** @sa enum_mdl_duration. */ 61 typedef int opaque_mdl_duration; 62 63 /** @sa MDL_wait::enum_wait_status. */ 64 typedef int opaque_mdl_status; 65 66 /** @sa enum_vio_type. */ 67 typedef int opaque_vio_type; 68 69 struct TABLE_SHARE; 70 71 struct sql_digest_storage; 72 73 #ifdef __cplusplus 74 class THD; 75 #else 76 /* 77 Phony declaration when compiling C code. 78 This is ok, because the C code will never have a THD anyway. 79 */ 80 struct opaque_THD 81 { 82 int dummy; 83 }; 84 typedef struct opaque_THD THD; 85 #endif 86 87 /** 88 @file mysql/psi/psi.h 89 Performance schema instrumentation interface. 90 91 @defgroup Instrumentation_interface Instrumentation Interface 92 @ingroup Performance_schema 93 @{ 94 */ 95 96 /** 97 Interface for an instrumented mutex. 98 This is an opaque structure. 99 */ 100 struct PSI_mutex; 101 typedef struct PSI_mutex PSI_mutex; 102 103 /** 104 Interface for an instrumented rwlock. 105 This is an opaque structure. 106 */ 107 struct PSI_rwlock; 108 typedef struct PSI_rwlock PSI_rwlock; 109 110 /** 111 Interface for an instrumented condition. 112 This is an opaque structure. 113 */ 114 struct PSI_cond; 115 typedef struct PSI_cond PSI_cond; 116 117 /** 118 Interface for an instrumented table share. 119 This is an opaque structure. 120 */ 121 struct PSI_table_share; 122 typedef struct PSI_table_share PSI_table_share; 123 124 /** 125 Interface for an instrumented table handle. 126 This is an opaque structure. 127 */ 128 struct PSI_table; 129 typedef struct PSI_table PSI_table; 130 131 /** 132 Interface for an instrumented thread. 133 This is an opaque structure. 134 */ 135 struct PSI_thread; 136 typedef struct PSI_thread PSI_thread; 137 138 /** 139 Interface for an instrumented file handle. 140 This is an opaque structure. 141 */ 142 struct PSI_file; 143 typedef struct PSI_file PSI_file; 144 145 /** 146 Interface for an instrumented socket descriptor. 147 This is an opaque structure. 148 */ 149 struct PSI_socket; 150 typedef struct PSI_socket PSI_socket; 151 152 /** 153 Interface for an instrumented prepared statement. 154 This is an opaque structure. 155 */ 156 struct PSI_prepared_stmt; 157 typedef struct PSI_prepared_stmt PSI_prepared_stmt; 158 159 /** 160 Interface for an instrumented table operation. 161 This is an opaque structure. 162 */ 163 struct PSI_table_locker; 164 typedef struct PSI_table_locker PSI_table_locker; 165 166 /** 167 Interface for an instrumented statement. 168 This is an opaque structure. 169 */ 170 struct PSI_statement_locker; 171 typedef struct PSI_statement_locker PSI_statement_locker; 172 173 /** 174 Interface for an instrumented transaction. 175 This is an opaque structure. 176 */ 177 struct PSI_transaction_locker; 178 typedef struct PSI_transaction_locker PSI_transaction_locker; 179 180 /** 181 Interface for an instrumented idle operation. 182 This is an opaque structure. 183 */ 184 struct PSI_idle_locker; 185 typedef struct PSI_idle_locker PSI_idle_locker; 186 187 /** 188 Interface for an instrumented statement digest operation. 189 This is an opaque structure. 190 */ 191 struct PSI_digest_locker; 192 typedef struct PSI_digest_locker PSI_digest_locker; 193 194 /** 195 Interface for an instrumented stored procedure share. 196 This is an opaque structure. 197 */ 198 struct PSI_sp_share; 199 typedef struct PSI_sp_share PSI_sp_share; 200 201 /** 202 Interface for an instrumented stored program. 203 This is an opaque structure. 204 */ 205 struct PSI_sp_locker; 206 typedef struct PSI_sp_locker PSI_sp_locker; 207 208 /** 209 Interface for an instrumented metadata lock. 210 This is an opaque structure. 211 */ 212 struct PSI_metadata_lock; 213 typedef struct PSI_metadata_lock PSI_metadata_lock; 214 215 /** 216 Interface for an instrumented stage progress. 217 This is a public structure, for efficiency. 218 */ 219 struct PSI_stage_progress 220 { 221 ulonglong m_work_completed; 222 ulonglong m_work_estimated; 223 }; 224 typedef struct PSI_stage_progress PSI_stage_progress; 225 226 /** IO operation performed on an instrumented table. */ 227 enum PSI_table_io_operation 228 { 229 /** Row fetch. */ 230 PSI_TABLE_FETCH_ROW= 0, 231 /** Row write. */ 232 PSI_TABLE_WRITE_ROW= 1, 233 /** Row update. */ 234 PSI_TABLE_UPDATE_ROW= 2, 235 /** Row delete. */ 236 PSI_TABLE_DELETE_ROW= 3 237 }; 238 typedef enum PSI_table_io_operation PSI_table_io_operation; 239 240 /** 241 State data storage for @c start_table_io_wait_v1_t, 242 @c start_table_lock_wait_v1_t. 243 This structure provide temporary storage to a table locker. 244 The content of this structure is considered opaque, 245 the fields are only hints of what an implementation 246 of the psi interface can use. 247 This memory is provided by the instrumented code for performance reasons. 248 @sa start_table_io_wait_v1_t 249 @sa start_table_lock_wait_v1_t 250 */ 251 struct PSI_table_locker_state 252 { 253 /** Internal state. */ 254 uint m_flags; 255 /** Current io operation. */ 256 enum PSI_table_io_operation m_io_operation; 257 /** Current table handle. */ 258 struct PSI_table *m_table; 259 /** Current table share. */ 260 struct PSI_table_share *m_table_share; 261 /** Current thread. */ 262 struct PSI_thread *m_thread; 263 /** Timer start. */ 264 ulonglong m_timer_start; 265 /** Timer function. */ 266 ulonglong (*m_timer)(void); 267 /** Internal data. */ 268 void *m_wait; 269 /** 270 Implementation specific. 271 For table io, the table io index. 272 For table lock, the lock type. 273 */ 274 uint m_index; 275 }; 276 typedef struct PSI_table_locker_state PSI_table_locker_state; 277 278 /** Entry point for the performance schema interface. */ 279 struct PSI_bootstrap 280 { 281 /** 282 ABI interface finder. 283 Calling this method with an interface version number returns either 284 an instance of the ABI for this version, or NULL. 285 @param version the interface version number to find 286 @return a versioned interface (PSI_v1, PSI_v2 or PSI) 287 @sa PSI_VERSION_1 288 @sa PSI_v1 289 @sa PSI_VERSION_2 290 @sa PSI_v2 291 @sa PSI_CURRENT_VERSION 292 @sa PSI 293 */ 294 void* (*get_interface)(int version); 295 }; 296 typedef struct PSI_bootstrap PSI_bootstrap; 297 298 #ifdef HAVE_PSI_INTERFACE 299 300 #ifdef DISABLE_ALL_PSI 301 302 #ifndef DISABLE_PSI_THREAD 303 #define DISABLE_PSI_THREAD 304 #endif 305 306 #ifndef DISABLE_PSI_MUTEX 307 #define DISABLE_PSI_MUTEX 308 #endif 309 310 #ifndef DISABLE_PSI_RWLOCK 311 #define DISABLE_PSI_RWLOCK 312 #endif 313 314 #ifndef DISABLE_PSI_COND 315 #define DISABLE_PSI_COND 316 #endif 317 318 #ifndef DISABLE_PSI_FILE 319 #define DISABLE_PSI_FILE 320 #endif 321 322 #ifndef DISABLE_PSI_TABLE 323 #define DISABLE_PSI_TABLE 324 #endif 325 326 #ifndef DISABLE_PSI_SOCKET 327 #define DISABLE_PSI_SOCKET 328 #endif 329 330 #ifndef DISABLE_PSI_STAGE 331 #define DISABLE_PSI_STAGE 332 #endif 333 334 #ifndef DISABLE_PSI_STATEMENT 335 #define DISABLE_PSI_STATEMENT 336 #endif 337 338 #ifndef DISABLE_PSI_SP 339 #define DISABLE_PSI_SP 340 #endif 341 342 #ifndef DISABLE_PSI_IDLE 343 #define DISABLE_PSI_IDLE 344 #endif 345 346 #ifndef DISABLE_PSI_STATEMENT_DIGEST 347 #define DISABLE_PSI_STATEMENT_DIGEST 348 #endif 349 350 #ifndef DISABLE_PSI_METADATA 351 #define DISABLE_PSI_METADATA 352 #endif 353 354 #ifndef DISABLE_PSI_MEMORY 355 #define DISABLE_PSI_MEMORY 356 #endif 357 358 #ifndef DISABLE_PSI_TRANSACTION 359 #define DISABLE_PSI_TRANSACTION 360 #endif 361 362 #ifndef DISABLE_PSI_SP 363 #define DISABLE_PSI_SP 364 #endif 365 366 #ifndef DISABLE_PSI_PS 367 #define DISABLE_PSI_PS 368 #endif 369 370 #endif 371 372 /** 373 @def DISABLE_PSI_MUTEX 374 Compiling option to disable the mutex instrumentation. 375 This option is mostly intended to be used during development, 376 when doing special builds with only a subset of the performance schema instrumentation, 377 for code analysis / profiling / performance tuning of a specific instrumentation alone. 378 @sa DISABLE_PSI_RWLOCK 379 @sa DISABLE_PSI_COND 380 @sa DISABLE_PSI_FILE 381 @sa DISABLE_PSI_THREAD 382 @sa DISABLE_PSI_TABLE 383 @sa DISABLE_PSI_STAGE 384 @sa DISABLE_PSI_STATEMENT 385 @sa DISABLE_PSI_SP 386 @sa DISABLE_PSI_STATEMENT_DIGEST 387 @sa DISABLE_PSI_SOCKET 388 @sa DISABLE_PSI_MEMORY 389 @sa DISABLE_PSI_IDLE 390 @sa DISABLE_PSI_METADATA 391 @sa DISABLE PSI_TRANSACTION 392 */ 393 394 #ifndef DISABLE_PSI_MUTEX 395 #define HAVE_PSI_MUTEX_INTERFACE 396 #endif 397 398 /** 399 @def DISABLE_PSI_RWLOCK 400 Compiling option to disable the rwlock instrumentation. 401 @sa DISABLE_PSI_MUTEX 402 */ 403 404 #ifndef DISABLE_PSI_RWLOCK 405 #define HAVE_PSI_RWLOCK_INTERFACE 406 #endif 407 408 /** 409 @def DISABLE_PSI_COND 410 Compiling option to disable the cond instrumentation. 411 @sa DISABLE_PSI_MUTEX 412 */ 413 414 #ifndef DISABLE_PSI_COND 415 #define HAVE_PSI_COND_INTERFACE 416 #endif 417 418 /** 419 @def DISABLE_PSI_FILE 420 Compiling option to disable the file instrumentation. 421 @sa DISABLE_PSI_MUTEX 422 */ 423 424 #ifndef DISABLE_PSI_FILE 425 #define HAVE_PSI_FILE_INTERFACE 426 #endif 427 428 /** 429 @def DISABLE_PSI_THREAD 430 Compiling option to disable the thread instrumentation. 431 @sa DISABLE_PSI_MUTEX 432 */ 433 #ifndef DISABLE_PSI_THREAD 434 #define HAVE_PSI_THREAD_INTERFACE 435 #endif 436 437 /** 438 @def DISABLE_PSI_TABLE 439 Compiling option to disable the table instrumentation. 440 @sa DISABLE_PSI_MUTEX 441 */ 442 443 #ifndef DISABLE_PSI_TABLE 444 #define HAVE_PSI_TABLE_INTERFACE 445 #endif 446 447 /** 448 @def DISABLE_PSI_STAGE 449 Compiling option to disable the stage instrumentation. 450 @sa DISABLE_PSI_MUTEX 451 */ 452 453 #ifndef DISABLE_PSI_STAGE 454 #define HAVE_PSI_STAGE_INTERFACE 455 #endif 456 457 /** 458 @def DISABLE_PSI_STATEMENT 459 Compiling option to disable the statement instrumentation. 460 @sa DISABLE_PSI_MUTEX 461 */ 462 463 #ifndef DISABLE_PSI_STATEMENT 464 #define HAVE_PSI_STATEMENT_INTERFACE 465 #endif 466 467 /** 468 @def DISABLE_PSI_SP 469 Compiling option to disable the stored program instrumentation. 470 @sa DISABLE_PSI_MUTEX 471 */ 472 #ifndef DISABLE_PSI_SP 473 #define HAVE_PSI_SP_INTERFACE 474 #endif 475 476 /** 477 @def DISABLE_PSI_PS 478 Compiling option to disable the prepared statement instrumentation. 479 @sa DISABLE_PSI_MUTEX 480 */ 481 #ifndef DISABLE_PSI_STATEMENT 482 #ifndef DISABLE_PSI_PS 483 #define HAVE_PSI_PS_INTERFACE 484 #endif 485 #endif 486 487 /** 488 @def DISABLE_PSI_STATEMENT_DIGEST 489 Compiling option to disable the statement digest instrumentation. 490 */ 491 492 #ifndef DISABLE_PSI_STATEMENT 493 #ifndef DISABLE_PSI_STATEMENT_DIGEST 494 #define HAVE_PSI_STATEMENT_DIGEST_INTERFACE 495 #endif 496 #endif 497 498 /** 499 @def DISABLE_PSI_TRANSACTION 500 Compiling option to disable the transaction instrumentation. 501 @sa DISABLE_PSI_MUTEX 502 */ 503 504 #ifndef DISABLE_PSI_TRANSACTION 505 #define HAVE_PSI_TRANSACTION_INTERFACE 506 #endif 507 508 /** 509 @def DISABLE_PSI_SOCKET 510 Compiling option to disable the statement instrumentation. 511 @sa DISABLE_PSI_MUTEX 512 */ 513 514 #ifndef DISABLE_PSI_SOCKET 515 #define HAVE_PSI_SOCKET_INTERFACE 516 #endif 517 518 /** 519 @def DISABLE_PSI_MEMORY 520 Compiling option to disable the memory instrumentation. 521 @sa DISABLE_PSI_MUTEX 522 */ 523 524 #ifndef DISABLE_PSI_MEMORY 525 #define HAVE_PSI_MEMORY_INTERFACE 526 #endif 527 528 /** 529 @def DISABLE_PSI_IDLE 530 Compiling option to disable the idle instrumentation. 531 @sa DISABLE_PSI_MUTEX 532 */ 533 534 #ifndef DISABLE_PSI_IDLE 535 #define HAVE_PSI_IDLE_INTERFACE 536 #endif 537 538 /** 539 @def DISABLE_PSI_METADATA 540 Compiling option to disable the metadata instrumentation. 541 @sa DISABLE_PSI_MUTEX 542 */ 543 544 #ifndef DISABLE_PSI_METADATA 545 #define HAVE_PSI_METADATA_INTERFACE 546 #endif 547 548 /** 549 @def PSI_VERSION_1 550 Performance Schema Interface number for version 1. 551 This version is supported. 552 */ 553 #define PSI_VERSION_1 1 554 555 /** 556 @def PSI_VERSION_2 557 Performance Schema Interface number for version 2. 558 This version is not implemented, it's a placeholder. 559 */ 560 #define PSI_VERSION_2 2 561 562 /** 563 @def PSI_CURRENT_VERSION 564 Performance Schema Interface number for the most recent version. 565 The most current version is @c PSI_VERSION_1 566 */ 567 #define PSI_CURRENT_VERSION 1 568 569 #ifndef USE_PSI_2 570 #ifndef USE_PSI_1 571 #define USE_PSI_1 572 #endif 573 #endif 574 575 /** 576 Interface for an instrumented mutex operation. 577 This is an opaque structure. 578 */ 579 struct PSI_mutex_locker; 580 typedef struct PSI_mutex_locker PSI_mutex_locker; 581 582 /** 583 Interface for an instrumented rwlock operation. 584 This is an opaque structure. 585 */ 586 struct PSI_rwlock_locker; 587 typedef struct PSI_rwlock_locker PSI_rwlock_locker; 588 589 /** 590 Interface for an instrumented condition operation. 591 This is an opaque structure. 592 */ 593 struct PSI_cond_locker; 594 typedef struct PSI_cond_locker PSI_cond_locker; 595 596 /** 597 Interface for an instrumented file operation. 598 This is an opaque structure. 599 */ 600 struct PSI_file_locker; 601 typedef struct PSI_file_locker PSI_file_locker; 602 603 /** 604 Interface for an instrumented socket operation. 605 This is an opaque structure. 606 */ 607 struct PSI_socket_locker; 608 typedef struct PSI_socket_locker PSI_socket_locker; 609 610 /** 611 Interface for an instrumented MDL operation. 612 This is an opaque structure. 613 */ 614 struct PSI_metadata_locker; 615 typedef struct PSI_metadata_locker PSI_metadata_locker; 616 617 /** Operation performed on an instrumented mutex. */ 618 enum PSI_mutex_operation 619 { 620 /** Lock. */ 621 PSI_MUTEX_LOCK= 0, 622 /** Lock attempt. */ 623 PSI_MUTEX_TRYLOCK= 1 624 }; 625 typedef enum PSI_mutex_operation PSI_mutex_operation; 626 627 /** 628 Operation performed on an instrumented rwlock. 629 For basic READ / WRITE lock, 630 operations are "READ" or "WRITE". 631 For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE". 632 */ 633 enum PSI_rwlock_operation 634 { 635 /** Read lock. */ 636 PSI_RWLOCK_READLOCK= 0, 637 /** Write lock. */ 638 PSI_RWLOCK_WRITELOCK= 1, 639 /** Read lock attempt. */ 640 PSI_RWLOCK_TRYREADLOCK= 2, 641 /** Write lock attempt. */ 642 PSI_RWLOCK_TRYWRITELOCK= 3, 643 644 /** Shared lock. */ 645 PSI_RWLOCK_SHAREDLOCK= 4, 646 /** Shared Exclusive lock. */ 647 PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5, 648 /** Exclusive lock. */ 649 PSI_RWLOCK_EXCLUSIVELOCK= 6, 650 /** Shared lock attempt. */ 651 PSI_RWLOCK_TRYSHAREDLOCK= 7, 652 /** Shared Exclusive lock attempt. */ 653 PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8, 654 /** Exclusive lock attempt. */ 655 PSI_RWLOCK_TRYEXCLUSIVELOCK= 9 656 657 }; 658 typedef enum PSI_rwlock_operation PSI_rwlock_operation; 659 660 /** Operation performed on an instrumented condition. */ 661 enum PSI_cond_operation 662 { 663 /** Wait. */ 664 PSI_COND_WAIT= 0, 665 /** Wait, with timeout. */ 666 PSI_COND_TIMEDWAIT= 1 667 }; 668 typedef enum PSI_cond_operation PSI_cond_operation; 669 670 /** Operation performed on an instrumented file. */ 671 enum PSI_file_operation 672 { 673 /** File creation, as in @c create(). */ 674 PSI_FILE_CREATE= 0, 675 /** Temporary file creation, as in @c create_temp_file(). */ 676 PSI_FILE_CREATE_TMP= 1, 677 /** File open, as in @c open(). */ 678 PSI_FILE_OPEN= 2, 679 /** File open, as in @c fopen(). */ 680 PSI_FILE_STREAM_OPEN= 3, 681 /** File close, as in @c close(). */ 682 PSI_FILE_CLOSE= 4, 683 /** File close, as in @c fclose(). */ 684 PSI_FILE_STREAM_CLOSE= 5, 685 /** 686 Generic file read, such as @c fgets(), @c fgetc(), @c fread(), @c read(), 687 @c pread(). 688 */ 689 PSI_FILE_READ= 6, 690 /** 691 Generic file write, such as @c fputs(), @c fputc(), @c fprintf(), 692 @c vfprintf(), @c fwrite(), @c write(), @c pwrite(). 693 */ 694 PSI_FILE_WRITE= 7, 695 /** Generic file seek, such as @c fseek() or @c seek(). */ 696 PSI_FILE_SEEK= 8, 697 /** Generic file tell, such as @c ftell() or @c tell(). */ 698 PSI_FILE_TELL= 9, 699 /** File flush, as in @c fflush(). */ 700 PSI_FILE_FLUSH= 10, 701 /** File stat, as in @c stat(). */ 702 PSI_FILE_STAT= 11, 703 /** File stat, as in @c fstat(). */ 704 PSI_FILE_FSTAT= 12, 705 /** File chsize, as in @c my_chsize(). */ 706 PSI_FILE_CHSIZE= 13, 707 /** File delete, such as @c my_delete() or @c my_delete_with_symlink(). */ 708 PSI_FILE_DELETE= 14, 709 /** File rename, such as @c my_rename() or @c my_rename_with_symlink(). */ 710 PSI_FILE_RENAME= 15, 711 /** File sync, as in @c fsync() or @c my_sync(). */ 712 PSI_FILE_SYNC= 16 713 }; 714 typedef enum PSI_file_operation PSI_file_operation; 715 716 /** Lock operation performed on an instrumented table. */ 717 enum PSI_table_lock_operation 718 { 719 /** Table lock, in the server layer. */ 720 PSI_TABLE_LOCK= 0, 721 /** Table lock, in the storage engine layer. */ 722 PSI_TABLE_EXTERNAL_LOCK= 1 723 }; 724 typedef enum PSI_table_lock_operation PSI_table_lock_operation; 725 726 /** State of an instrumented socket. */ 727 enum PSI_socket_state 728 { 729 /** Idle, waiting for the next command. */ 730 PSI_SOCKET_STATE_IDLE= 1, 731 /** Active, executing a command. */ 732 PSI_SOCKET_STATE_ACTIVE= 2 733 }; 734 typedef enum PSI_socket_state PSI_socket_state; 735 736 /** Operation performed on an instrumented socket. */ 737 enum PSI_socket_operation 738 { 739 /** Socket creation, as in @c socket() or @c socketpair(). */ 740 PSI_SOCKET_CREATE= 0, 741 /** Socket connection, as in @c connect(), @c listen() and @c accept(). */ 742 PSI_SOCKET_CONNECT= 1, 743 /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */ 744 PSI_SOCKET_BIND= 2, 745 /** Socket close, as in @c shutdown(). */ 746 PSI_SOCKET_CLOSE= 3, 747 /** Socket send, @c send(). */ 748 PSI_SOCKET_SEND= 4, 749 /** Socket receive, @c recv(). */ 750 PSI_SOCKET_RECV= 5, 751 /** Socket send, @c sendto(). */ 752 PSI_SOCKET_SENDTO= 6, 753 /** Socket receive, @c recvfrom). */ 754 PSI_SOCKET_RECVFROM= 7, 755 /** Socket send, @c sendmsg(). */ 756 PSI_SOCKET_SENDMSG= 8, 757 /** Socket receive, @c recvmsg(). */ 758 PSI_SOCKET_RECVMSG= 9, 759 /** Socket seek, such as @c fseek() or @c seek(). */ 760 PSI_SOCKET_SEEK= 10, 761 /** Socket options, as in @c getsockopt() and @c setsockopt(). */ 762 PSI_SOCKET_OPT= 11, 763 /** Socket status, as in @c sockatmark() and @c isfdtype(). */ 764 PSI_SOCKET_STAT= 12, 765 /** Socket shutdown, as in @c shutdown(). */ 766 PSI_SOCKET_SHUTDOWN= 13, 767 /** Socket select, as in @c select() and @c poll(). */ 768 PSI_SOCKET_SELECT= 14 769 }; 770 typedef enum PSI_socket_operation PSI_socket_operation; 771 772 /** 773 Instrumented mutex key. 774 To instrument a mutex, a mutex key must be obtained using @c register_mutex. 775 Using a zero key always disable the instrumentation. 776 */ 777 typedef unsigned int PSI_mutex_key; 778 779 /** 780 Instrumented rwlock key. 781 To instrument a rwlock, a rwlock key must be obtained 782 using @c register_rwlock. 783 Using a zero key always disable the instrumentation. 784 */ 785 typedef unsigned int PSI_rwlock_key; 786 787 /** 788 Instrumented cond key. 789 To instrument a condition, a condition key must be obtained 790 using @c register_cond. 791 Using a zero key always disable the instrumentation. 792 */ 793 typedef unsigned int PSI_cond_key; 794 795 /** 796 Instrumented thread key. 797 To instrument a thread, a thread key must be obtained 798 using @c register_thread. 799 Using a zero key always disable the instrumentation. 800 */ 801 typedef unsigned int PSI_thread_key; 802 803 /** 804 Instrumented file key. 805 To instrument a file, a file key must be obtained using @c register_file. 806 Using a zero key always disable the instrumentation. 807 */ 808 #ifndef PSI_FILE_KEY_DEFINED 809 typedef unsigned int PSI_file_key; 810 #define PSI_FILE_KEY_DEFINED 811 #endif 812 813 /** 814 Instrumented stage key. 815 To instrument a stage, a stage key must be obtained using @c register_stage. 816 Using a zero key always disable the instrumentation. 817 */ 818 typedef unsigned int PSI_stage_key; 819 820 /** 821 Instrumented statement key. 822 To instrument a statement, a statement key must be obtained using @c register_statement. 823 Using a zero key always disable the instrumentation. 824 */ 825 typedef unsigned int PSI_statement_key; 826 827 /** 828 Instrumented socket key. 829 To instrument a socket, a socket key must be obtained using @c register_socket. 830 Using a zero key always disable the instrumentation. 831 */ 832 typedef unsigned int PSI_socket_key; 833 834 #ifdef HAVE_PSI_1 835 836 /** 837 @defgroup Group_PSI_v1 Application Binary Interface, version 1 838 @ingroup Instrumentation_interface 839 @{ 840 */ 841 842 /** 843 Mutex information. 844 @since PSI_VERSION_1 845 This structure is used to register an instrumented mutex. 846 */ 847 struct PSI_mutex_info_v1 848 { 849 /** 850 Pointer to the key assigned to the registered mutex. 851 */ 852 PSI_mutex_key *m_key; 853 /** 854 The name of the mutex to register. 855 */ 856 const char *m_name; 857 /** 858 The flags of the mutex to register. 859 @sa PSI_FLAG_GLOBAL 860 */ 861 int m_flags; 862 }; 863 typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1; 864 865 /** 866 Rwlock information. 867 @since PSI_VERSION_1 868 This structure is used to register an instrumented rwlock. 869 */ 870 struct PSI_rwlock_info_v1 871 { 872 /** 873 Pointer to the key assigned to the registered rwlock. 874 */ 875 PSI_rwlock_key *m_key; 876 /** 877 The name of the rwlock to register. 878 */ 879 const char *m_name; 880 /** 881 The flags of the rwlock to register. 882 @sa PSI_FLAG_GLOBAL 883 */ 884 int m_flags; 885 }; 886 typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1; 887 888 /** 889 Condition information. 890 @since PSI_VERSION_1 891 This structure is used to register an instrumented cond. 892 */ 893 struct PSI_cond_info_v1 894 { 895 /** 896 Pointer to the key assigned to the registered cond. 897 */ 898 PSI_cond_key *m_key; 899 /** 900 The name of the cond to register. 901 */ 902 const char *m_name; 903 /** 904 The flags of the cond to register. 905 @sa PSI_FLAG_GLOBAL 906 */ 907 int m_flags; 908 }; 909 typedef struct PSI_cond_info_v1 PSI_cond_info_v1; 910 911 /** 912 Thread instrument information. 913 @since PSI_VERSION_1 914 This structure is used to register an instrumented thread. 915 */ 916 struct PSI_thread_info_v1 917 { 918 /** 919 Pointer to the key assigned to the registered thread. 920 */ 921 PSI_thread_key *m_key; 922 /** 923 The name of the thread instrument to register. 924 */ 925 const char *m_name; 926 /** 927 The flags of the thread to register. 928 @sa PSI_FLAG_GLOBAL 929 */ 930 int m_flags; 931 }; 932 typedef struct PSI_thread_info_v1 PSI_thread_info_v1; 933 934 /** 935 File instrument information. 936 @since PSI_VERSION_1 937 This structure is used to register an instrumented file. 938 */ 939 struct PSI_file_info_v1 940 { 941 /** 942 Pointer to the key assigned to the registered file. 943 */ 944 PSI_file_key *m_key; 945 /** 946 The name of the file instrument to register. 947 */ 948 const char *m_name; 949 /** 950 The flags of the file instrument to register. 951 @sa PSI_FLAG_GLOBAL 952 */ 953 int m_flags; 954 }; 955 typedef struct PSI_file_info_v1 PSI_file_info_v1; 956 957 /** 958 Stage instrument information. 959 @since PSI_VERSION_1 960 This structure is used to register an instrumented stage. 961 */ 962 struct PSI_stage_info_v1 963 { 964 /** The registered stage key. */ 965 PSI_stage_key m_key; 966 /** The name of the stage instrument to register. */ 967 const char *m_name; 968 /** The flags of the stage instrument to register. */ 969 int m_flags; 970 }; 971 typedef struct PSI_stage_info_v1 PSI_stage_info_v1; 972 973 /** 974 Statement instrument information. 975 @since PSI_VERSION_1 976 This structure is used to register an instrumented statement. 977 */ 978 struct PSI_statement_info_v1 979 { 980 /** The registered statement key. */ 981 PSI_statement_key m_key; 982 /** The name of the statement instrument to register. */ 983 const char *m_name; 984 /** The flags of the statement instrument to register. */ 985 int m_flags; 986 }; 987 typedef struct PSI_statement_info_v1 PSI_statement_info_v1; 988 989 /** 990 Socket instrument information. 991 @since PSI_VERSION_1 992 This structure is used to register an instrumented socket. 993 */ 994 struct PSI_socket_info_v1 995 { 996 /** 997 Pointer to the key assigned to the registered socket. 998 */ 999 PSI_socket_key *m_key; 1000 /** 1001 The name of the socket instrument to register. 1002 */ 1003 const char *m_name; 1004 /** 1005 The flags of the socket instrument to register. 1006 @sa PSI_FLAG_GLOBAL 1007 */ 1008 int m_flags; 1009 }; 1010 typedef struct PSI_socket_info_v1 PSI_socket_info_v1; 1011 1012 /** 1013 State data storage for @c start_idle_wait_v1_t. 1014 This structure provide temporary storage to an idle locker. 1015 The content of this structure is considered opaque, 1016 the fields are only hints of what an implementation 1017 of the psi interface can use. 1018 This memory is provided by the instrumented code for performance reasons. 1019 @sa start_idle_wait_v1_t. 1020 */ 1021 struct PSI_idle_locker_state_v1 1022 { 1023 /** Internal state. */ 1024 uint m_flags; 1025 /** Current thread. */ 1026 struct PSI_thread *m_thread; 1027 /** Timer start. */ 1028 ulonglong m_timer_start; 1029 /** Timer function. */ 1030 ulonglong (*m_timer)(void); 1031 /** Internal data. */ 1032 void *m_wait; 1033 }; 1034 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1; 1035 1036 /** 1037 State data storage for @c start_mutex_wait_v1_t. 1038 This structure provide temporary storage to a mutex locker. 1039 The content of this structure is considered opaque, 1040 the fields are only hints of what an implementation 1041 of the psi interface can use. 1042 This memory is provided by the instrumented code for performance reasons. 1043 @sa start_mutex_wait_v1_t 1044 */ 1045 struct PSI_mutex_locker_state_v1 1046 { 1047 /** Internal state. */ 1048 uint m_flags; 1049 /** Current operation. */ 1050 enum PSI_mutex_operation m_operation; 1051 /** Current mutex. */ 1052 struct PSI_mutex *m_mutex; 1053 /** Current thread. */ 1054 struct PSI_thread *m_thread; 1055 /** Timer start. */ 1056 ulonglong m_timer_start; 1057 /** Timer function. */ 1058 ulonglong (*m_timer)(void); 1059 /** Internal data. */ 1060 void *m_wait; 1061 }; 1062 typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1; 1063 1064 /** 1065 State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t. 1066 This structure provide temporary storage to a rwlock locker. 1067 The content of this structure is considered opaque, 1068 the fields are only hints of what an implementation 1069 of the psi interface can use. 1070 This memory is provided by the instrumented code for performance reasons. 1071 @sa start_rwlock_rdwait_v1_t 1072 @sa start_rwlock_wrwait_v1_t 1073 */ 1074 struct PSI_rwlock_locker_state_v1 1075 { 1076 /** Internal state. */ 1077 uint m_flags; 1078 /** Current operation. */ 1079 enum PSI_rwlock_operation m_operation; 1080 /** Current rwlock. */ 1081 struct PSI_rwlock *m_rwlock; 1082 /** Current thread. */ 1083 struct PSI_thread *m_thread; 1084 /** Timer start. */ 1085 ulonglong m_timer_start; 1086 /** Timer function. */ 1087 ulonglong (*m_timer)(void); 1088 /** Internal data. */ 1089 void *m_wait; 1090 }; 1091 typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1; 1092 1093 /** 1094 State data storage for @c start_cond_wait_v1_t. 1095 This structure provide temporary storage to a condition locker. 1096 The content of this structure is considered opaque, 1097 the fields are only hints of what an implementation 1098 of the psi interface can use. 1099 This memory is provided by the instrumented code for performance reasons. 1100 @sa start_cond_wait_v1_t 1101 */ 1102 struct PSI_cond_locker_state_v1 1103 { 1104 /** Internal state. */ 1105 uint m_flags; 1106 /** Current operation. */ 1107 enum PSI_cond_operation m_operation; 1108 /** Current condition. */ 1109 struct PSI_cond *m_cond; 1110 /** Current mutex. */ 1111 struct PSI_mutex *m_mutex; 1112 /** Current thread. */ 1113 struct PSI_thread *m_thread; 1114 /** Timer start. */ 1115 ulonglong m_timer_start; 1116 /** Timer function. */ 1117 ulonglong (*m_timer)(void); 1118 /** Internal data. */ 1119 void *m_wait; 1120 }; 1121 typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1; 1122 1123 /** 1124 State data storage for @c get_thread_file_name_locker_v1_t. 1125 This structure provide temporary storage to a file locker. 1126 The content of this structure is considered opaque, 1127 the fields are only hints of what an implementation 1128 of the psi interface can use. 1129 This memory is provided by the instrumented code for performance reasons. 1130 @sa get_thread_file_name_locker_v1_t 1131 @sa get_thread_file_stream_locker_v1_t 1132 @sa get_thread_file_descriptor_locker_v1_t 1133 */ 1134 struct PSI_file_locker_state_v1 1135 { 1136 /** Internal state. */ 1137 uint m_flags; 1138 /** Current operation. */ 1139 enum PSI_file_operation m_operation; 1140 /** Current file. */ 1141 struct PSI_file *m_file; 1142 /** Current file name. */ 1143 const char *m_name; 1144 /** Current file class. */ 1145 void *m_class; 1146 /** Current thread. */ 1147 struct PSI_thread *m_thread; 1148 /** Operation number of bytes. */ 1149 size_t m_number_of_bytes; 1150 /** Timer start. */ 1151 ulonglong m_timer_start; 1152 /** Timer function. */ 1153 ulonglong (*m_timer)(void); 1154 /** Internal data. */ 1155 void *m_wait; 1156 }; 1157 typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1; 1158 1159 /** 1160 State data storage for @c start_metadata_wait_v1_t. 1161 This structure provide temporary storage to a metadata locker. 1162 The content of this structure is considered opaque, 1163 the fields are only hints of what an implementation 1164 of the psi interface can use. 1165 This memory is provided by the instrumented code for performance reasons. 1166 @sa start_metadata_wait_v1_t 1167 */ 1168 struct PSI_metadata_locker_state_v1 1169 { 1170 /** Internal state. */ 1171 uint m_flags; 1172 /** Current metadata lock. */ 1173 struct PSI_metadata_lock *m_metadata_lock; 1174 /** Current thread. */ 1175 struct PSI_thread *m_thread; 1176 /** Timer start. */ 1177 ulonglong m_timer_start; 1178 /** Timer function. */ 1179 ulonglong (*m_timer)(void); 1180 /** Internal data. */ 1181 void *m_wait; 1182 }; 1183 typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1; 1184 1185 /* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */ 1186 #define PSI_SCHEMA_NAME_LEN (64 * 3) 1187 1188 /** 1189 State data storage for @c get_thread_statement_locker_v1_t, 1190 @c get_thread_statement_locker_v1_t. 1191 This structure provide temporary storage to a statement locker. 1192 The content of this structure is considered opaque, 1193 the fields are only hints of what an implementation 1194 of the psi interface can use. 1195 This memory is provided by the instrumented code for performance reasons. 1196 @sa get_thread_statement_locker_v1_t 1197 */ 1198 struct PSI_statement_locker_state_v1 1199 { 1200 /** Discarded flag. */ 1201 my_bool m_discarded; 1202 /** In prepare flag. */ 1203 my_bool m_in_prepare; 1204 /** Metric, no index used flag. */ 1205 uchar m_no_index_used; 1206 /** Metric, no good index used flag. */ 1207 uchar m_no_good_index_used; 1208 /** Internal state. */ 1209 uint m_flags; 1210 /** Instrumentation class. */ 1211 void *m_class; 1212 /** Current thread. */ 1213 struct PSI_thread *m_thread; 1214 /** Timer start. */ 1215 ulonglong m_timer_start; 1216 /** Timer function. */ 1217 ulonglong (*m_timer)(void); 1218 /** Internal data. */ 1219 void *m_statement; 1220 /** Locked time. */ 1221 ulonglong m_lock_time; 1222 /** Rows sent. */ 1223 ulonglong m_rows_sent; 1224 /** Rows examined. */ 1225 ulonglong m_rows_examined; 1226 /** Metric, temporary tables created on disk. */ 1227 ulong m_created_tmp_disk_tables; 1228 /** Metric, temporary tables created. */ 1229 ulong m_created_tmp_tables; 1230 /** Metric, number of select full join. */ 1231 ulong m_select_full_join; 1232 /** Metric, number of select full range join. */ 1233 ulong m_select_full_range_join; 1234 /** Metric, number of select range. */ 1235 ulong m_select_range; 1236 /** Metric, number of select range check. */ 1237 ulong m_select_range_check; 1238 /** Metric, number of select scan. */ 1239 ulong m_select_scan; 1240 /** Metric, number of sort merge passes. */ 1241 ulong m_sort_merge_passes; 1242 /** Metric, number of sort merge. */ 1243 ulong m_sort_range; 1244 /** Metric, number of sort rows. */ 1245 ulong m_sort_rows; 1246 /** Metric, number of sort scans. */ 1247 ulong m_sort_scan; 1248 /** Statement digest. */ 1249 const struct sql_digest_storage *m_digest; 1250 /** Current schema name. */ 1251 char m_schema_name[PSI_SCHEMA_NAME_LEN]; 1252 /** Length in bytes of @c m_schema_name. */ 1253 uint m_schema_name_length; 1254 /** Statement character set number. */ 1255 uint m_cs_number; 1256 PSI_sp_share *m_parent_sp_share; 1257 PSI_prepared_stmt *m_parent_prepared_stmt; 1258 }; 1259 typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1; 1260 1261 /** 1262 State data storage for @c get_thread_transaction_locker_v1_t, 1263 @c get_thread_transaction_locker_v1_t. 1264 This structure provide temporary storage to a transaction locker. 1265 The content of this structure is considered opaque, 1266 the fields are only hints of what an implementation 1267 of the psi interface can use. 1268 This memory is provided by the instrumented code for performance reasons. 1269 @sa get_thread_transaction_locker_v1_t 1270 */ 1271 struct PSI_transaction_locker_state_v1 1272 { 1273 /** Internal state. */ 1274 uint m_flags; 1275 /** Instrumentation class. */ 1276 void *m_class; 1277 /** Current thread. */ 1278 struct PSI_thread *m_thread; 1279 /** Timer start. */ 1280 ulonglong m_timer_start; 1281 /** Timer function. */ 1282 ulonglong (*m_timer)(void); 1283 /** Internal data. */ 1284 void *m_transaction; 1285 /** True if read-only transaction, false if read-write. */ 1286 my_bool m_read_only; 1287 /** True if transaction is autocommit. */ 1288 my_bool m_autocommit; 1289 /** Number of statements. */ 1290 ulong m_statement_count; 1291 /** Total number of savepoints. */ 1292 ulong m_savepoint_count; 1293 /** Number of rollback_to_savepoint. */ 1294 ulong m_rollback_to_savepoint_count; 1295 /** Number of release_savepoint. */ 1296 ulong m_release_savepoint_count; 1297 }; 1298 1299 typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1; 1300 1301 /** 1302 State data storage for @c start_socket_wait_v1_t. 1303 This structure provide temporary storage to a socket locker. 1304 The content of this structure is considered opaque, 1305 the fields are only hints of what an implementation 1306 of the psi interface can use. 1307 This memory is provided by the instrumented code for performance reasons. 1308 @sa start_socket_wait_v1_t 1309 */ 1310 struct PSI_socket_locker_state_v1 1311 { 1312 /** Internal state. */ 1313 uint m_flags; 1314 /** Current socket. */ 1315 struct PSI_socket *m_socket; 1316 /** Current thread. */ 1317 struct PSI_thread *m_thread; 1318 /** Operation number of bytes. */ 1319 size_t m_number_of_bytes; 1320 /** Timer start. */ 1321 ulonglong m_timer_start; 1322 /** Timer function. */ 1323 ulonglong (*m_timer)(void); 1324 /** Current operation. */ 1325 enum PSI_socket_operation m_operation; 1326 /** Source file. */ 1327 const char* m_src_file; 1328 /** Source line number. */ 1329 int m_src_line; 1330 /** Internal data. */ 1331 void *m_wait; 1332 }; 1333 typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1; 1334 1335 struct PSI_sp_locker_state_v1 1336 { 1337 /** Internal state. */ 1338 uint m_flags; 1339 /** Current thread. */ 1340 struct PSI_thread *m_thread; 1341 /** Timer start. */ 1342 ulonglong m_timer_start; 1343 /** Timer function. */ 1344 ulonglong (*m_timer)(void); 1345 /** Stored Procedure share. */ 1346 PSI_sp_share* m_sp_share; 1347 }; 1348 typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1; 1349 1350 /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */ 1351 1352 /** 1353 Mutex registration API. 1354 @param category a category name (typically a plugin name) 1355 @param info an array of mutex info to register 1356 @param count the size of the info array 1357 */ 1358 typedef void (*register_mutex_v1_t) 1359 (const char *category, struct PSI_mutex_info_v1 *info, int count); 1360 1361 /** 1362 Rwlock registration API. 1363 @param category a category name (typically a plugin name) 1364 @param info an array of rwlock info to register 1365 @param count the size of the info array 1366 */ 1367 typedef void (*register_rwlock_v1_t) 1368 (const char *category, struct PSI_rwlock_info_v1 *info, int count); 1369 1370 /** 1371 Cond registration API. 1372 @param category a category name (typically a plugin name) 1373 @param info an array of cond info to register 1374 @param count the size of the info array 1375 */ 1376 typedef void (*register_cond_v1_t) 1377 (const char *category, struct PSI_cond_info_v1 *info, int count); 1378 1379 /** 1380 Thread registration API. 1381 @param category a category name (typically a plugin name) 1382 @param info an array of thread info to register 1383 @param count the size of the info array 1384 */ 1385 typedef void (*register_thread_v1_t) 1386 (const char *category, struct PSI_thread_info_v1 *info, int count); 1387 1388 /** 1389 File registration API. 1390 @param category a category name (typically a plugin name) 1391 @param info an array of file info to register 1392 @param count the size of the info array 1393 */ 1394 typedef void (*register_file_v1_t) 1395 (const char *category, struct PSI_file_info_v1 *info, int count); 1396 1397 /** 1398 Stage registration API. 1399 @param category a category name 1400 @param info an array of stage info to register 1401 @param count the size of the info array 1402 */ 1403 typedef void (*register_stage_v1_t) 1404 (const char *category, struct PSI_stage_info_v1 **info, int count); 1405 1406 /** 1407 Statement registration API. 1408 @param category a category name 1409 @param info an array of stage info to register 1410 @param count the size of the info array 1411 */ 1412 typedef void (*register_statement_v1_t) 1413 (const char *category, struct PSI_statement_info_v1 *info, int count); 1414 1415 /** 1416 Socket registration API. 1417 @param category a category name (typically a plugin name) 1418 @param info an array of socket info to register 1419 @param count the size of the info array 1420 */ 1421 typedef void (*register_socket_v1_t) 1422 (const char *category, struct PSI_socket_info_v1 *info, int count); 1423 1424 /** 1425 Mutex instrumentation initialisation API. 1426 @param key the registered mutex key 1427 @param identity the address of the mutex itself 1428 @return an instrumented mutex 1429 */ 1430 typedef struct PSI_mutex* (*init_mutex_v1_t) 1431 (PSI_mutex_key key, const void *identity); 1432 1433 /** 1434 Mutex instrumentation destruction API. 1435 @param mutex the mutex to destroy 1436 */ 1437 typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex); 1438 1439 /** 1440 Rwlock instrumentation initialisation API. 1441 @param key the registered rwlock key 1442 @param identity the address of the rwlock itself 1443 @return an instrumented rwlock 1444 */ 1445 typedef struct PSI_rwlock* (*init_rwlock_v1_t) 1446 (PSI_rwlock_key key, const void *identity); 1447 1448 /** 1449 Rwlock instrumentation destruction API. 1450 @param rwlock the rwlock to destroy 1451 */ 1452 typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock); 1453 1454 /** 1455 Cond instrumentation initialisation API. 1456 @param key the registered key 1457 @param identity the address of the rwlock itself 1458 @return an instrumented cond 1459 */ 1460 typedef struct PSI_cond* (*init_cond_v1_t) 1461 (PSI_cond_key key, const void *identity); 1462 1463 /** 1464 Cond instrumentation destruction API. 1465 @param cond the rcond to destroy 1466 */ 1467 typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond); 1468 1469 /** 1470 Socket instrumentation initialisation API. 1471 @param key the registered mutex key 1472 @param socket descriptor 1473 @param addr the socket ip address 1474 @param addr_len length of socket ip address 1475 @return an instrumented socket 1476 */ 1477 typedef struct PSI_socket* (*init_socket_v1_t) 1478 (PSI_socket_key key, const my_socket *fd, 1479 const struct sockaddr *addr, socklen_t addr_len); 1480 1481 /** 1482 socket instrumentation destruction API. 1483 @param socket the socket to destroy 1484 */ 1485 typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket); 1486 1487 /** 1488 Acquire a table share instrumentation. 1489 @param temporary True for temporary tables 1490 @param share The SQL layer table share 1491 @return a table share instrumentation, or NULL 1492 */ 1493 typedef struct PSI_table_share* (*get_table_share_v1_t) 1494 (my_bool temporary, struct TABLE_SHARE *share); 1495 1496 /** 1497 Release a table share. 1498 @param info the table share to release 1499 */ 1500 typedef void (*release_table_share_v1_t)(struct PSI_table_share *share); 1501 1502 /** 1503 Drop a table share. 1504 @param temporary True for temporary tables 1505 @param schema_name the table schema name 1506 @param schema_name_length the table schema name length 1507 @param table_name the table name 1508 @param table_name_length the table name length 1509 */ 1510 typedef void (*drop_table_share_v1_t) 1511 (my_bool temporary, const char *schema_name, int schema_name_length, 1512 const char *table_name, int table_name_length); 1513 1514 /** 1515 Open an instrumentation table handle. 1516 @param share the table to open 1517 @param identity table handle identity 1518 @return a table handle, or NULL 1519 */ 1520 typedef struct PSI_table* (*open_table_v1_t) 1521 (struct PSI_table_share *share, const void *identity); 1522 1523 /** 1524 Unbind a table handle from the current thread. 1525 This operation happens when an opened table is added to the open table cache. 1526 @param table the table to unbind 1527 */ 1528 typedef void (*unbind_table_v1_t) 1529 (struct PSI_table *table); 1530 1531 /** 1532 Rebind a table handle to the current thread. 1533 This operation happens when a table from the open table cache 1534 is reused for a thread. 1535 @param table the table to unbind 1536 */ 1537 typedef PSI_table* (*rebind_table_v1_t) 1538 (PSI_table_share *share, const void *identity, PSI_table *table); 1539 1540 /** 1541 Close an instrumentation table handle. 1542 Note that the table handle is invalid after this call. 1543 @param table the table handle to close 1544 */ 1545 typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share, 1546 struct PSI_table *table); 1547 1548 /** 1549 Create a file instrumentation for a created file. 1550 This method does not create the file itself, but is used to notify the 1551 instrumentation interface that a file was just created. 1552 @param key the file instrumentation key for this file 1553 @param name the file name 1554 @param file the file handle 1555 */ 1556 typedef void (*create_file_v1_t)(PSI_file_key key, const char *name, 1557 File file); 1558 1559 /** 1560 Spawn a thread. 1561 This method creates a new thread, with instrumentation. 1562 @param key the instrumentation key for this thread 1563 @param thread the resulting thread 1564 @param attr the thread attributes 1565 @param start_routine the thread start routine 1566 @param arg the thread start routine argument 1567 */ 1568 typedef int (*spawn_thread_v1_t)(PSI_thread_key key, 1569 my_thread_handle *thread, 1570 const my_thread_attr_t *attr, 1571 void *(*start_routine)(void*), void *arg); 1572 1573 /** 1574 Create instrumentation for a thread. 1575 @param key the registered key 1576 @param identity an address typical of the thread 1577 @return an instrumented thread 1578 */ 1579 typedef struct PSI_thread* (*new_thread_v1_t) 1580 (PSI_thread_key key, const void *identity, ulonglong thread_id); 1581 1582 /** 1583 Assign a THD to an instrumented thread. 1584 @param thread the instrumented thread 1585 @param THD the sql layer THD to assign 1586 */ 1587 typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread, 1588 THD *thd); 1589 1590 /** 1591 Assign an id to an instrumented thread. 1592 @param thread the instrumented thread 1593 @param id the id to assign 1594 */ 1595 typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread, 1596 ulonglong id); 1597 1598 /** 1599 Assign the current operating system thread id to an instrumented thread. 1600 The operating system task id is obtained from @c gettid() 1601 @param thread the instrumented thread 1602 */ 1603 typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread); 1604 1605 /** 1606 Get the instrumentation for the running thread. 1607 For this function to return a result, 1608 the thread instrumentation must have been attached to the 1609 running thread using @c set_thread() 1610 @return the instrumentation for the running thread 1611 */ 1612 typedef struct PSI_thread* (*get_thread_v1_t)(void); 1613 1614 /** 1615 Assign a user name to the instrumented thread. 1616 @param user the user name 1617 @param user_len the user name length 1618 */ 1619 typedef void (*set_thread_user_v1_t)(const char *user, int user_len); 1620 1621 /** 1622 Assign a user name and host name to the instrumented thread. 1623 @param user the user name 1624 @param user_len the user name length 1625 @param host the host name 1626 @param host_len the host name length 1627 */ 1628 typedef void (*set_thread_account_v1_t)(const char *user, int user_len, 1629 const char *host, int host_len); 1630 1631 /** 1632 Assign a current database to the instrumented thread. 1633 @param db the database name 1634 @param db_len the database name length 1635 */ 1636 typedef void (*set_thread_db_v1_t)(const char* db, int db_len); 1637 1638 /** 1639 Assign a current command to the instrumented thread. 1640 @param command the current command 1641 */ 1642 typedef void (*set_thread_command_v1_t)(int command); 1643 1644 /** 1645 Assign a connection type to the instrumented thread. 1646 @param conn_type the connection type 1647 */ 1648 typedef void (*set_connection_type_v1_t)(opaque_vio_type conn_type); 1649 1650 1651 /** 1652 Assign a start time to the instrumented thread. 1653 @param start_time the thread start time 1654 */ 1655 typedef void (*set_thread_start_time_v1_t)(time_t start_time); 1656 1657 /** 1658 Assign a state to the instrumented thread. 1659 @param state the thread state 1660 */ 1661 typedef void (*set_thread_state_v1_t)(const char* state); 1662 1663 /** 1664 Assign a process info to the instrumented thread. 1665 @param info the process into string 1666 @param info_len the process into string length 1667 */ 1668 typedef void (*set_thread_info_v1_t)(const char* info, uint info_len); 1669 1670 /** 1671 Attach a thread instrumentation to the running thread. 1672 In case of thread pools, this method should be called when 1673 a worker thread picks a work item and runs it. 1674 Also, this method should be called if the instrumented code does not 1675 keep the pointer returned by @c new_thread() and relies on @c get_thread() 1676 instead. 1677 @param thread the thread instrumentation 1678 */ 1679 typedef void (*set_thread_v1_t)(struct PSI_thread *thread); 1680 1681 /** Delete the current thread instrumentation. */ 1682 typedef void (*delete_current_thread_v1_t)(void); 1683 1684 /** Delete a thread instrumentation. */ 1685 typedef void (*delete_thread_v1_t)(struct PSI_thread *thread); 1686 1687 /** 1688 Get a file instrumentation locker, for opening or creating a file. 1689 @param state data storage for the locker 1690 @param key the file instrumentation key 1691 @param op the operation to perform 1692 @param name the file name 1693 @param identity a pointer representative of this file. 1694 @return a file locker, or NULL 1695 */ 1696 typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t) 1697 (struct PSI_file_locker_state_v1 *state, 1698 PSI_file_key key, enum PSI_file_operation op, const char *name, 1699 const void *identity); 1700 1701 /** 1702 Get a file stream instrumentation locker. 1703 @param state data storage for the locker 1704 @param file the file stream to access 1705 @param op the operation to perform 1706 @return a file locker, or NULL 1707 */ 1708 typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t) 1709 (struct PSI_file_locker_state_v1 *state, 1710 struct PSI_file *file, enum PSI_file_operation op); 1711 1712 /** 1713 Get a file instrumentation locker. 1714 @param state data storage for the locker 1715 @param file the file descriptor to access 1716 @param op the operation to perform 1717 @return a file locker, or NULL 1718 */ 1719 typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t) 1720 (struct PSI_file_locker_state_v1 *state, 1721 File file, enum PSI_file_operation op); 1722 1723 /** 1724 Record a mutex instrumentation unlock event. 1725 @param mutex the mutex instrumentation 1726 */ 1727 typedef void (*unlock_mutex_v1_t) 1728 (struct PSI_mutex *mutex); 1729 1730 /** 1731 Record a rwlock instrumentation unlock event. 1732 @param rwlock the rwlock instrumentation 1733 */ 1734 typedef void (*unlock_rwlock_v1_t) 1735 (struct PSI_rwlock *rwlock); 1736 1737 /** 1738 Record a condition instrumentation signal event. 1739 @param cond the cond instrumentation 1740 */ 1741 typedef void (*signal_cond_v1_t) 1742 (struct PSI_cond *cond); 1743 1744 /** 1745 Record a condition instrumentation broadcast event. 1746 @param cond the cond instrumentation 1747 */ 1748 typedef void (*broadcast_cond_v1_t) 1749 (struct PSI_cond *cond); 1750 1751 /** 1752 Record an idle instrumentation wait start event. 1753 @param state data storage for the locker 1754 @param file the source file name 1755 @param line the source line number 1756 @return an idle locker, or NULL 1757 */ 1758 typedef struct PSI_idle_locker* (*start_idle_wait_v1_t) 1759 (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line); 1760 1761 /** 1762 Record an idle instrumentation wait end event. 1763 @param locker a thread locker for the running thread 1764 */ 1765 typedef void (*end_idle_wait_v1_t) 1766 (struct PSI_idle_locker *locker); 1767 1768 /** 1769 Record a mutex instrumentation wait start event. 1770 @param state data storage for the locker 1771 @param mutex the instrumented mutex to lock 1772 @param op the operation to perform 1773 @param file the source file name 1774 @param line the source line number 1775 @return a mutex locker, or NULL 1776 */ 1777 typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t) 1778 (struct PSI_mutex_locker_state_v1 *state, 1779 struct PSI_mutex *mutex, 1780 enum PSI_mutex_operation op, 1781 const char *src_file, uint src_line); 1782 1783 /** 1784 Record a mutex instrumentation wait end event. 1785 @param locker a thread locker for the running thread 1786 @param rc the wait operation return code 1787 */ 1788 typedef void (*end_mutex_wait_v1_t) 1789 (struct PSI_mutex_locker *locker, int rc); 1790 1791 /** 1792 Record a rwlock instrumentation read wait start event. 1793 @param locker a thread locker for the running thread 1794 @param must must block: 1 for lock, 0 for trylock 1795 */ 1796 typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t) 1797 (struct PSI_rwlock_locker_state_v1 *state, 1798 struct PSI_rwlock *rwlock, 1799 enum PSI_rwlock_operation op, 1800 const char *src_file, uint src_line); 1801 1802 /** 1803 Record a rwlock instrumentation read wait end event. 1804 @param locker a thread locker for the running thread 1805 @param rc the wait operation return code 1806 */ 1807 typedef void (*end_rwlock_rdwait_v1_t) 1808 (struct PSI_rwlock_locker *locker, int rc); 1809 1810 /** 1811 Record a rwlock instrumentation write wait start event. 1812 @param locker a thread locker for the running thread 1813 @param must must block: 1 for lock, 0 for trylock 1814 */ 1815 typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t) 1816 (struct PSI_rwlock_locker_state_v1 *state, 1817 struct PSI_rwlock *rwlock, 1818 enum PSI_rwlock_operation op, 1819 const char *src_file, uint src_line); 1820 1821 /** 1822 Record a rwlock instrumentation write wait end event. 1823 @param locker a thread locker for the running thread 1824 @param rc the wait operation return code 1825 */ 1826 typedef void (*end_rwlock_wrwait_v1_t) 1827 (struct PSI_rwlock_locker *locker, int rc); 1828 1829 /** 1830 Record a condition instrumentation wait start event. 1831 @param locker a thread locker for the running thread 1832 @param must must block: 1 for wait, 0 for timedwait 1833 */ 1834 typedef struct PSI_cond_locker* (*start_cond_wait_v1_t) 1835 (struct PSI_cond_locker_state_v1 *state, 1836 struct PSI_cond *cond, 1837 struct PSI_mutex *mutex, 1838 enum PSI_cond_operation op, 1839 const char *src_file, uint src_line); 1840 1841 /** 1842 Record a condition instrumentation wait end event. 1843 @param locker a thread locker for the running thread 1844 @param rc the wait operation return code 1845 */ 1846 typedef void (*end_cond_wait_v1_t) 1847 (struct PSI_cond_locker *locker, int rc); 1848 1849 /** 1850 Record a table instrumentation io wait start event. 1851 @param locker a table locker for the running thread 1852 @param file the source file name 1853 @param line the source line number 1854 */ 1855 typedef struct PSI_table_locker* (*start_table_io_wait_v1_t) 1856 (struct PSI_table_locker_state *state, 1857 struct PSI_table *table, 1858 enum PSI_table_io_operation op, 1859 uint index, 1860 const char *src_file, uint src_line); 1861 1862 /** 1863 Record a table instrumentation io wait end event. 1864 @param locker a table locker for the running thread 1865 @param numrows the number of rows involved in io 1866 */ 1867 typedef void (*end_table_io_wait_v1_t) 1868 (struct PSI_table_locker *locker, 1869 ulonglong numrows); 1870 1871 /** 1872 Record a table instrumentation lock wait start event. 1873 @param locker a table locker for the running thread 1874 @param file the source file name 1875 @param line the source line number 1876 */ 1877 typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t) 1878 (struct PSI_table_locker_state *state, 1879 struct PSI_table *table, 1880 enum PSI_table_lock_operation op, 1881 ulong flags, 1882 const char *src_file, uint src_line); 1883 1884 /** 1885 Record a table instrumentation lock wait end event. 1886 @param locker a table locker for the running thread 1887 */ 1888 typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker); 1889 1890 typedef void (*unlock_table_v1_t)(struct PSI_table *table); 1891 1892 /** 1893 Start a file instrumentation open operation. 1894 @param locker the file locker 1895 @param op the operation to perform 1896 @param src_file the source file name 1897 @param src_line the source line number 1898 */ 1899 typedef void (*start_file_open_wait_v1_t) 1900 (struct PSI_file_locker *locker, const char *src_file, uint src_line); 1901 1902 /** 1903 End a file instrumentation open operation, for file streams. 1904 @param locker the file locker. 1905 @param result the opened file (NULL indicates failure, non NULL success). 1906 @return an instrumented file handle 1907 */ 1908 typedef struct PSI_file* (*end_file_open_wait_v1_t) 1909 (struct PSI_file_locker *locker, void *result); 1910 1911 /** 1912 End a file instrumentation open operation, for non stream files. 1913 @param locker the file locker. 1914 @param file the file number assigned by open() or create() for this file. 1915 */ 1916 typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t) 1917 (struct PSI_file_locker *locker, File file); 1918 1919 /** 1920 End a file instrumentation open operation, for non stream temporary files. 1921 @param locker the file locker. 1922 @param file the file number assigned by open() or create() for this file. 1923 @param filename the file name generated during temporary file creation. 1924 */ 1925 typedef void (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t) 1926 (struct PSI_file_locker *locker, File file, const char *filename); 1927 1928 /** 1929 Record a file instrumentation start event. 1930 @param locker a file locker for the running thread 1931 @param op file operation to be performed 1932 @param count the number of bytes requested, or 0 if not applicable 1933 @param src_file the source file name 1934 @param src_line the source line number 1935 */ 1936 typedef void (*start_file_wait_v1_t) 1937 (struct PSI_file_locker *locker, size_t count, 1938 const char *src_file, uint src_line); 1939 1940 /** 1941 Record a file instrumentation end event. 1942 Note that for file close operations, the instrumented file handle 1943 associated with the file (which was provided to obtain a locker) 1944 is invalid after this call. 1945 @param locker a file locker for the running thread 1946 @param count the number of bytes actually used in the operation, 1947 or 0 if not applicable, or -1 if the operation failed 1948 @sa get_thread_file_name_locker 1949 @sa get_thread_file_stream_locker 1950 @sa get_thread_file_descriptor_locker 1951 */ 1952 typedef void (*end_file_wait_v1_t) 1953 (struct PSI_file_locker *locker, size_t count); 1954 1955 /** 1956 Start a file instrumentation close operation. 1957 @param locker the file locker 1958 @param op the operation to perform 1959 @param src_file the source file name 1960 @param src_line the source line number 1961 */ 1962 typedef void (*start_file_close_wait_v1_t) 1963 (struct PSI_file_locker *locker, const char *src_file, uint src_line); 1964 1965 /** 1966 End a file instrumentation close operation. 1967 @param locker the file locker. 1968 @param rc the close operation return code (0 for success). 1969 @return an instrumented file handle 1970 */ 1971 typedef void (*end_file_close_wait_v1_t) 1972 (struct PSI_file_locker *locker, int rc); 1973 1974 /** 1975 Rename a file instrumentation close operation. 1976 @param locker the file locker. 1977 @param old_name name of the file to be renamed. 1978 @param new_name name of the file after rename. 1979 @param rc the rename operation return code (0 for success). 1980 */ 1981 typedef void (*end_file_rename_wait_v1_t) 1982 (struct PSI_file_locker *locker, const char *old_name, 1983 const char *new_name, int rc); 1984 1985 /** 1986 Start a new stage, and implicitly end the previous stage. 1987 @param key the key of the new stage 1988 @param src_file the source file name 1989 @param src_line the source line number 1990 @return the new stage progress 1991 */ 1992 typedef PSI_stage_progress* (*start_stage_v1_t) 1993 (PSI_stage_key key, const char *src_file, int src_line); 1994 1995 typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void); 1996 1997 /** End the current stage. */ 1998 typedef void (*end_stage_v1_t) (void); 1999 2000 /** 2001 Get a statement instrumentation locker. 2002 @param state data storage for the locker 2003 @param key the statement instrumentation key 2004 @param charset client character set 2005 @return a statement locker, or NULL 2006 */ 2007 typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t) 2008 (struct PSI_statement_locker_state_v1 *state, 2009 PSI_statement_key key, const void *charset, PSI_sp_share *sp_share); 2010 2011 /** 2012 Refine a statement locker to a more specific key. 2013 Note that only events declared mutable can be refined. 2014 @param the statement locker for the current event 2015 @param key the new key for the event 2016 @sa PSI_FLAG_MUTABLE 2017 */ 2018 typedef struct PSI_statement_locker* (*refine_statement_v1_t) 2019 (struct PSI_statement_locker *locker, 2020 PSI_statement_key key); 2021 2022 /** 2023 Start a new statement event. 2024 @param locker the statement locker for this event 2025 @param db the active database name for this statement 2026 @param db_length the active database name length for this statement 2027 @param src_file source file name 2028 @param src_line source line number 2029 */ 2030 typedef void (*start_statement_v1_t) 2031 (struct PSI_statement_locker *locker, 2032 const char *db, uint db_length, 2033 const char *src_file, uint src_line); 2034 2035 /** 2036 Set the statement text for a statement event. 2037 @param locker the current statement locker 2038 @param text the statement text 2039 @param text_len the statement text length 2040 */ 2041 typedef void (*set_statement_text_v1_t) 2042 (struct PSI_statement_locker *locker, 2043 const char *text, uint text_len); 2044 2045 /** 2046 Set a statement event lock time. 2047 @param locker the statement locker 2048 @param lock_time the locked time, in microseconds 2049 */ 2050 typedef void (*set_statement_lock_time_t) 2051 (struct PSI_statement_locker *locker, ulonglong lock_time); 2052 2053 /** 2054 Set a statement event rows sent metric. 2055 @param locker the statement locker 2056 @param count the number of rows sent 2057 */ 2058 typedef void (*set_statement_rows_sent_t) 2059 (struct PSI_statement_locker *locker, ulonglong count); 2060 2061 /** 2062 Set a statement event rows examined metric. 2063 @param locker the statement locker 2064 @param count the number of rows examined 2065 */ 2066 typedef void (*set_statement_rows_examined_t) 2067 (struct PSI_statement_locker *locker, ulonglong count); 2068 2069 /** 2070 Increment a statement event "created tmp disk tables" metric. 2071 @param locker the statement locker 2072 @param count the metric increment value 2073 */ 2074 typedef void (*inc_statement_created_tmp_disk_tables_t) 2075 (struct PSI_statement_locker *locker, ulong count); 2076 2077 /** 2078 Increment a statement event "created tmp tables" metric. 2079 @param locker the statement locker 2080 @param count the metric increment value 2081 */ 2082 typedef void (*inc_statement_created_tmp_tables_t) 2083 (struct PSI_statement_locker *locker, ulong count); 2084 2085 /** 2086 Increment a statement event "select full join" metric. 2087 @param locker the statement locker 2088 @param count the metric increment value 2089 */ 2090 typedef void (*inc_statement_select_full_join_t) 2091 (struct PSI_statement_locker *locker, ulong count); 2092 2093 /** 2094 Increment a statement event "select full range join" metric. 2095 @param locker the statement locker 2096 @param count the metric increment value 2097 */ 2098 typedef void (*inc_statement_select_full_range_join_t) 2099 (struct PSI_statement_locker *locker, ulong count); 2100 2101 /** 2102 Increment a statement event "select range join" metric. 2103 @param locker the statement locker 2104 @param count the metric increment value 2105 */ 2106 typedef void (*inc_statement_select_range_t) 2107 (struct PSI_statement_locker *locker, ulong count); 2108 2109 /** 2110 Increment a statement event "select range check" metric. 2111 @param locker the statement locker 2112 @param count the metric increment value 2113 */ 2114 typedef void (*inc_statement_select_range_check_t) 2115 (struct PSI_statement_locker *locker, ulong count); 2116 2117 /** 2118 Increment a statement event "select scan" metric. 2119 @param locker the statement locker 2120 @param count the metric increment value 2121 */ 2122 typedef void (*inc_statement_select_scan_t) 2123 (struct PSI_statement_locker *locker, ulong count); 2124 2125 /** 2126 Increment a statement event "sort merge passes" metric. 2127 @param locker the statement locker 2128 @param count the metric increment value 2129 */ 2130 typedef void (*inc_statement_sort_merge_passes_t) 2131 (struct PSI_statement_locker *locker, ulong count); 2132 2133 /** 2134 Increment a statement event "sort range" metric. 2135 @param locker the statement locker 2136 @param count the metric increment value 2137 */ 2138 typedef void (*inc_statement_sort_range_t) 2139 (struct PSI_statement_locker *locker, ulong count); 2140 2141 /** 2142 Increment a statement event "sort rows" metric. 2143 @param locker the statement locker 2144 @param count the metric increment value 2145 */ 2146 typedef void (*inc_statement_sort_rows_t) 2147 (struct PSI_statement_locker *locker, ulong count); 2148 2149 /** 2150 Increment a statement event "sort scan" metric. 2151 @param locker the statement locker 2152 @param count the metric increment value 2153 */ 2154 typedef void (*inc_statement_sort_scan_t) 2155 (struct PSI_statement_locker *locker, ulong count); 2156 2157 /** 2158 Set a statement event "no index used" metric. 2159 @param locker the statement locker 2160 @param count the metric value 2161 */ 2162 typedef void (*set_statement_no_index_used_t) 2163 (struct PSI_statement_locker *locker); 2164 2165 /** 2166 Set a statement event "no good index used" metric. 2167 @param locker the statement locker 2168 @param count the metric value 2169 */ 2170 typedef void (*set_statement_no_good_index_used_t) 2171 (struct PSI_statement_locker *locker); 2172 2173 /** 2174 End a statement event. 2175 @param locker the statement locker 2176 @param stmt_da the statement diagnostics area. 2177 @sa Diagnostics_area 2178 */ 2179 typedef void (*end_statement_v1_t) 2180 (struct PSI_statement_locker *locker, void *stmt_da); 2181 2182 /** 2183 Get a transaction instrumentation locker. 2184 @param state data storage for the locker 2185 @param xid the xid for this transaction 2186 @param trxid the InnoDB transaction id 2187 @param iso_level isolation level for this transaction 2188 @param read_only true if transaction access mode is read-only 2189 @param autocommit true if transaction is autocommit 2190 @return a transaction locker, or NULL 2191 */ 2192 typedef struct PSI_transaction_locker* (*get_thread_transaction_locker_v1_t) 2193 (struct PSI_transaction_locker_state_v1 *state, const void *xid, 2194 const ulonglong *trxid, int isolation_level, my_bool read_only, 2195 my_bool autocommit); 2196 2197 /** 2198 Start a new transaction event. 2199 @param locker the transaction locker for this event 2200 @param src_file source file name 2201 @param src_line source line number 2202 */ 2203 typedef void (*start_transaction_v1_t) 2204 (struct PSI_transaction_locker *locker, 2205 const char *src_file, uint src_line); 2206 2207 /** 2208 Set the transaction xid. 2209 @param locker the transaction locker for this event 2210 @param xid the id of the XA transaction 2211 #param xa_state is the state of the XA transaction 2212 */ 2213 typedef void (*set_transaction_xid_v1_t) 2214 (struct PSI_transaction_locker *locker, 2215 const void *xid, int xa_state); 2216 2217 /** 2218 Set the state of the XA transaction. 2219 @param locker the transaction locker for this event 2220 @param xa_state the new state of the xa transaction 2221 */ 2222 typedef void (*set_transaction_xa_state_v1_t) 2223 (struct PSI_transaction_locker *locker, 2224 int xa_state); 2225 2226 /** 2227 Set the transaction gtid. 2228 @param locker the transaction locker for this event 2229 @param sid the source id for the transaction, mapped from sidno 2230 @param gtid_spec the gtid specifier for the transaction 2231 */ 2232 typedef void (*set_transaction_gtid_v1_t) 2233 (struct PSI_transaction_locker *locker, 2234 const void *sid, const void *gtid_spec); 2235 2236 /** 2237 Set the transaction trx_id. 2238 @param locker the transaction locker for this event 2239 @param trxid the storage engine transaction ID 2240 */ 2241 typedef void (*set_transaction_trxid_v1_t) 2242 (struct PSI_transaction_locker *locker, 2243 const ulonglong *trxid); 2244 2245 /** 2246 Increment a transaction event savepoint count. 2247 @param locker the transaction locker 2248 @param count the increment value 2249 */ 2250 typedef void (*inc_transaction_savepoints_v1_t) 2251 (struct PSI_transaction_locker *locker, ulong count); 2252 2253 /** 2254 Increment a transaction event rollback to savepoint count. 2255 @param locker the transaction locker 2256 @param count the increment value 2257 */ 2258 typedef void (*inc_transaction_rollback_to_savepoint_v1_t) 2259 (struct PSI_transaction_locker *locker, ulong count); 2260 2261 /** 2262 Increment a transaction event release savepoint count. 2263 @param locker the transaction locker 2264 @param count the increment value 2265 */ 2266 typedef void (*inc_transaction_release_savepoint_v1_t) 2267 (struct PSI_transaction_locker *locker, ulong count); 2268 2269 /** 2270 Commit or rollback the transaction. 2271 @param locker the transaction locker for this event 2272 @param commit true if transaction was committed, false if rolled back 2273 */ 2274 typedef void (*end_transaction_v1_t) 2275 (struct PSI_transaction_locker *locker, 2276 my_bool commit); 2277 2278 /** 2279 Record a socket instrumentation start event. 2280 @param locker a socket locker for the running thread 2281 @param op socket operation to be performed 2282 @param count the number of bytes requested, or 0 if not applicable 2283 @param src_file the source file name 2284 @param src_line the source line number 2285 */ 2286 typedef struct PSI_socket_locker* (*start_socket_wait_v1_t) 2287 (struct PSI_socket_locker_state_v1 *state, 2288 struct PSI_socket *socket, 2289 enum PSI_socket_operation op, 2290 size_t count, 2291 const char *src_file, uint src_line); 2292 2293 /** 2294 Record a socket instrumentation end event. 2295 Note that for socket close operations, the instrumented socket handle 2296 associated with the socket (which was provided to obtain a locker) 2297 is invalid after this call. 2298 @param locker a socket locker for the running thread 2299 @param count the number of bytes actually used in the operation, 2300 or 0 if not applicable, or -1 if the operation failed 2301 @sa get_thread_socket_locker 2302 */ 2303 typedef void (*end_socket_wait_v1_t) 2304 (struct PSI_socket_locker *locker, size_t count); 2305 2306 /** 2307 Set the socket state for an instrumented socket. 2308 @param socket the instrumented socket 2309 @param state socket state 2310 */ 2311 typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket, 2312 enum PSI_socket_state state); 2313 2314 /** 2315 Set the socket info for an instrumented socket. 2316 @param socket the instrumented socket 2317 @param fd the socket descriptor 2318 @param addr the socket ip address 2319 @param addr_len length of socket ip address 2320 @param thread_id associated thread id 2321 */ 2322 typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket, 2323 const my_socket *fd, 2324 const struct sockaddr *addr, 2325 socklen_t addr_len); 2326 2327 /** 2328 Bind a socket to the thread that owns it. 2329 @param socket instrumented socket 2330 */ 2331 typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket); 2332 2333 /** 2334 Get a prepare statement. 2335 @param locker a statement locker for the running thread. 2336 */ 2337 typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t) 2338 (void *identity, uint stmt_id, PSI_statement_locker *locker, 2339 const char *stmt_name, size_t stmt_name_length, 2340 const char *name, size_t length); 2341 2342 /** 2343 destroy a prepare statement. 2344 @param prepared_stmt prepared statement. 2345 */ 2346 typedef void (*destroy_prepared_stmt_v1_t) 2347 (PSI_prepared_stmt *prepared_stmt); 2348 2349 /** 2350 repreare a prepare statement. 2351 @param prepared_stmt prepared statement. 2352 */ 2353 typedef void (*reprepare_prepared_stmt_v1_t) 2354 (PSI_prepared_stmt *prepared_stmt); 2355 2356 /** 2357 Record a prepare statement instrumentation execute event. 2358 @param locker a statement locker for the running thread. 2359 @param prepared_stmt prepared statement. 2360 */ 2361 typedef void (*execute_prepared_stmt_v1_t) 2362 (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt); 2363 2364 /** 2365 Set the statement text for a prepared statment event. 2366 @param prepared_stmt prepared statement. 2367 @param text the prepared statement text 2368 @param text_len the prepared statement text length 2369 */ 2370 typedef void (*set_prepared_stmt_text_v1_t)(PSI_prepared_stmt *prepared_stmt, 2371 const char *text, 2372 uint text_len); 2373 /** 2374 Get a digest locker for the current statement. 2375 @param locker a statement locker for the running thread 2376 */ 2377 typedef struct PSI_digest_locker * (*digest_start_v1_t) 2378 (struct PSI_statement_locker *locker); 2379 2380 /** 2381 Add a token to the current digest instrumentation. 2382 @param locker a digest locker for the current statement 2383 @param token the lexical token to add 2384 @param yylval the lexical token attributes 2385 */ 2386 typedef void (*digest_end_v1_t) 2387 (struct PSI_digest_locker *locker, const struct sql_digest_storage *digest); 2388 2389 typedef PSI_sp_locker* (*start_sp_v1_t) 2390 (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share); 2391 2392 typedef void (*end_sp_v1_t) 2393 (struct PSI_sp_locker *locker); 2394 2395 typedef void (*drop_sp_v1_t) 2396 (uint object_type, 2397 const char *schema_name, uint schema_name_length, 2398 const char *object_name, uint object_name_length); 2399 2400 /** 2401 Acquire a sp share instrumentation. 2402 @param type of stored program 2403 @param schema name of stored program 2404 @param name of stored program 2405 @return a stored program share instrumentation, or NULL 2406 */ 2407 typedef struct PSI_sp_share* (*get_sp_share_v1_t) 2408 (uint object_type, 2409 const char *schema_name, uint schema_name_length, 2410 const char *object_name, uint object_name_length); 2411 2412 /** 2413 Release a stored program share. 2414 @param info the stored program share to release 2415 */ 2416 typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share); 2417 2418 typedef PSI_metadata_lock* (*create_metadata_lock_v1_t) 2419 (void *identity, 2420 const MDL_key *key, 2421 opaque_mdl_type mdl_type, 2422 opaque_mdl_duration mdl_duration, 2423 opaque_mdl_status mdl_status, 2424 const char *src_file, 2425 uint src_line); 2426 2427 typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock, 2428 opaque_mdl_status mdl_status); 2429 2430 typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock); 2431 2432 typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t) 2433 (struct PSI_metadata_locker_state_v1 *state, 2434 struct PSI_metadata_lock *mdl, 2435 const char *src_file, uint src_line); 2436 2437 typedef void (*end_metadata_wait_v1_t) 2438 (struct PSI_metadata_locker *locker, int rc); 2439 2440 /** 2441 Stores an array of connection attributes 2442 @param buffer char array of length encoded connection attributes 2443 in network format 2444 @param length length of the data in buffer 2445 @param from_cs charset in which @c buffer is encoded 2446 @return state 2447 @retval non_0 attributes truncated 2448 @retval 0 stored the attribute 2449 */ 2450 typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length, 2451 const void *from_cs); 2452 2453 /** 2454 Performance Schema Interface, version 1. 2455 @since PSI_VERSION_1 2456 */ 2457 struct PSI_v1 2458 { 2459 /** @sa register_mutex_v1_t. */ 2460 register_mutex_v1_t register_mutex; 2461 /** @sa register_rwlock_v1_t. */ 2462 register_rwlock_v1_t register_rwlock; 2463 /** @sa register_cond_v1_t. */ 2464 register_cond_v1_t register_cond; 2465 /** @sa register_thread_v1_t. */ 2466 register_thread_v1_t register_thread; 2467 /** @sa register_file_v1_t. */ 2468 register_file_v1_t register_file; 2469 /** @sa register_stage_v1_t. */ 2470 register_stage_v1_t register_stage; 2471 /** @sa register_statement_v1_t. */ 2472 register_statement_v1_t register_statement; 2473 /** @sa register_socket_v1_t. */ 2474 register_socket_v1_t register_socket; 2475 /** @sa init_mutex_v1_t. */ 2476 init_mutex_v1_t init_mutex; 2477 /** @sa destroy_mutex_v1_t. */ 2478 destroy_mutex_v1_t destroy_mutex; 2479 /** @sa init_rwlock_v1_t. */ 2480 init_rwlock_v1_t init_rwlock; 2481 /** @sa destroy_rwlock_v1_t. */ 2482 destroy_rwlock_v1_t destroy_rwlock; 2483 /** @sa init_cond_v1_t. */ 2484 init_cond_v1_t init_cond; 2485 /** @sa destroy_cond_v1_t. */ 2486 destroy_cond_v1_t destroy_cond; 2487 /** @sa init_socket_v1_t. */ 2488 init_socket_v1_t init_socket; 2489 /** @sa destroy_socket_v1_t. */ 2490 destroy_socket_v1_t destroy_socket; 2491 2492 /** @sa get_table_share_v1_t. */ 2493 get_table_share_v1_t get_table_share; 2494 /** @sa release_table_share_v1_t. */ 2495 release_table_share_v1_t release_table_share; 2496 /** @sa drop_table_share_v1_t. */ 2497 drop_table_share_v1_t drop_table_share; 2498 /** @sa open_table_v1_t. */ 2499 open_table_v1_t open_table; 2500 /** @sa unbind_table_v1_t. */ 2501 unbind_table_v1_t unbind_table; 2502 /** @sa rebind_table_v1_t. */ 2503 rebind_table_v1_t rebind_table; 2504 /** @sa close_table_v1_t. */ 2505 close_table_v1_t close_table; 2506 /** @sa create_file_v1_t. */ 2507 create_file_v1_t create_file; 2508 /** @sa spawn_thread_v1_t. */ 2509 spawn_thread_v1_t spawn_thread; 2510 /** @sa new_thread_v1_t. */ 2511 new_thread_v1_t new_thread; 2512 /** @sa set_thread_id_v1_t. */ 2513 set_thread_id_v1_t set_thread_id; 2514 /** @sa set_thread_THD_v1_t. */ 2515 set_thread_THD_v1_t set_thread_THD; 2516 /** @sa set_thread_os_id_v1_t. */ 2517 set_thread_os_id_v1_t set_thread_os_id; 2518 /** @sa get_thread_v1_t. */ 2519 get_thread_v1_t get_thread; 2520 /** @sa set_thread_user_v1_t. */ 2521 set_thread_user_v1_t set_thread_user; 2522 /** @sa set_thread_account_v1_t. */ 2523 set_thread_account_v1_t set_thread_account; 2524 /** @sa set_thread_db_v1_t. */ 2525 set_thread_db_v1_t set_thread_db; 2526 /** @sa set_thread_command_v1_t. */ 2527 set_thread_command_v1_t set_thread_command; 2528 /** @sa set_connection_type_v1_t. */ 2529 set_connection_type_v1_t set_connection_type; 2530 /** @sa set_thread_start_time_v1_t. */ 2531 set_thread_start_time_v1_t set_thread_start_time; 2532 /** @sa set_thread_state_v1_t. */ 2533 set_thread_state_v1_t set_thread_state; 2534 /** @sa set_thread_info_v1_t. */ 2535 set_thread_info_v1_t set_thread_info; 2536 /** @sa set_thread_v1_t. */ 2537 set_thread_v1_t set_thread; 2538 /** @sa delete_current_thread_v1_t. */ 2539 delete_current_thread_v1_t delete_current_thread; 2540 /** @sa delete_thread_v1_t. */ 2541 delete_thread_v1_t delete_thread; 2542 /** @sa get_thread_file_name_locker_v1_t. */ 2543 get_thread_file_name_locker_v1_t get_thread_file_name_locker; 2544 /** @sa get_thread_file_stream_locker_v1_t. */ 2545 get_thread_file_stream_locker_v1_t get_thread_file_stream_locker; 2546 /** @sa get_thread_file_descriptor_locker_v1_t. */ 2547 get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker; 2548 /** @sa unlock_mutex_v1_t. */ 2549 unlock_mutex_v1_t unlock_mutex; 2550 /** @sa unlock_rwlock_v1_t. */ 2551 unlock_rwlock_v1_t unlock_rwlock; 2552 /** @sa signal_cond_v1_t. */ 2553 signal_cond_v1_t signal_cond; 2554 /** @sa broadcast_cond_v1_t. */ 2555 broadcast_cond_v1_t broadcast_cond; 2556 /** @sa start_idle_wait_v1_t. */ 2557 start_idle_wait_v1_t start_idle_wait; 2558 /** @sa end_idle_wait_v1_t. */ 2559 end_idle_wait_v1_t end_idle_wait; 2560 /** @sa start_mutex_wait_v1_t. */ 2561 start_mutex_wait_v1_t start_mutex_wait; 2562 /** @sa end_mutex_wait_v1_t. */ 2563 end_mutex_wait_v1_t end_mutex_wait; 2564 /** @sa start_rwlock_rdwait_v1_t. */ 2565 start_rwlock_rdwait_v1_t start_rwlock_rdwait; 2566 /** @sa end_rwlock_rdwait_v1_t. */ 2567 end_rwlock_rdwait_v1_t end_rwlock_rdwait; 2568 /** @sa start_rwlock_wrwait_v1_t. */ 2569 start_rwlock_wrwait_v1_t start_rwlock_wrwait; 2570 /** @sa end_rwlock_wrwait_v1_t. */ 2571 end_rwlock_wrwait_v1_t end_rwlock_wrwait; 2572 /** @sa start_cond_wait_v1_t. */ 2573 start_cond_wait_v1_t start_cond_wait; 2574 /** @sa end_cond_wait_v1_t. */ 2575 end_cond_wait_v1_t end_cond_wait; 2576 /** @sa start_table_io_wait_v1_t. */ 2577 start_table_io_wait_v1_t start_table_io_wait; 2578 /** @sa end_table_io_wait_v1_t. */ 2579 end_table_io_wait_v1_t end_table_io_wait; 2580 /** @sa start_table_lock_wait_v1_t. */ 2581 start_table_lock_wait_v1_t start_table_lock_wait; 2582 /** @sa end_table_lock_wait_v1_t. */ 2583 end_table_lock_wait_v1_t end_table_lock_wait; 2584 /** @sa start_file_open_wait_v1_t. */ 2585 start_file_open_wait_v1_t start_file_open_wait; 2586 /** @sa end_file_open_wait_v1_t. */ 2587 end_file_open_wait_v1_t end_file_open_wait; 2588 /** @sa end_file_open_wait_and_bind_to_descriptor_v1_t. */ 2589 end_file_open_wait_and_bind_to_descriptor_v1_t 2590 end_file_open_wait_and_bind_to_descriptor; 2591 /** @sa end_temp_file_open_wait_and_bind_to_descriptor_v1_t. */ 2592 end_temp_file_open_wait_and_bind_to_descriptor_v1_t 2593 end_temp_file_open_wait_and_bind_to_descriptor; 2594 /** @sa start_file_wait_v1_t. */ 2595 start_file_wait_v1_t start_file_wait; 2596 /** @sa end_file_wait_v1_t. */ 2597 end_file_wait_v1_t end_file_wait; 2598 /** @sa start_file_close_wait_v1_t. */ 2599 start_file_close_wait_v1_t start_file_close_wait; 2600 /** @sa end_file_close_wait_v1_t. */ 2601 end_file_close_wait_v1_t end_file_close_wait; 2602 /** @sa rename_file_close_wait_v1_t. */ 2603 end_file_rename_wait_v1_t end_file_rename_wait; 2604 /** @sa start_stage_v1_t. */ 2605 start_stage_v1_t start_stage; 2606 /** @sa get_current_stage_progress_v1_t. */ 2607 get_current_stage_progress_v1_t get_current_stage_progress; 2608 /** @sa end_stage_v1_t. */ 2609 end_stage_v1_t end_stage; 2610 /** @sa get_thread_statement_locker_v1_t. */ 2611 get_thread_statement_locker_v1_t get_thread_statement_locker; 2612 /** @sa refine_statement_v1_t. */ 2613 refine_statement_v1_t refine_statement; 2614 /** @sa start_statement_v1_t. */ 2615 start_statement_v1_t start_statement; 2616 /** @sa set_statement_text_v1_t. */ 2617 set_statement_text_v1_t set_statement_text; 2618 /** @sa set_statement_lock_time_t. */ 2619 set_statement_lock_time_t set_statement_lock_time; 2620 /** @sa set_statement_rows_sent_t. */ 2621 set_statement_rows_sent_t set_statement_rows_sent; 2622 /** @sa set_statement_rows_examined_t. */ 2623 set_statement_rows_examined_t set_statement_rows_examined; 2624 /** @sa inc_statement_created_tmp_disk_tables. */ 2625 inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables; 2626 /** @sa inc_statement_created_tmp_tables. */ 2627 inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables; 2628 /** @sa inc_statement_select_full_join. */ 2629 inc_statement_select_full_join_t inc_statement_select_full_join; 2630 /** @sa inc_statement_select_full_range_join. */ 2631 inc_statement_select_full_range_join_t inc_statement_select_full_range_join; 2632 /** @sa inc_statement_select_range. */ 2633 inc_statement_select_range_t inc_statement_select_range; 2634 /** @sa inc_statement_select_range_check. */ 2635 inc_statement_select_range_check_t inc_statement_select_range_check; 2636 /** @sa inc_statement_select_scan. */ 2637 inc_statement_select_scan_t inc_statement_select_scan; 2638 /** @sa inc_statement_sort_merge_passes. */ 2639 inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes; 2640 /** @sa inc_statement_sort_range. */ 2641 inc_statement_sort_range_t inc_statement_sort_range; 2642 /** @sa inc_statement_sort_rows. */ 2643 inc_statement_sort_rows_t inc_statement_sort_rows; 2644 /** @sa inc_statement_sort_scan. */ 2645 inc_statement_sort_scan_t inc_statement_sort_scan; 2646 /** @sa set_statement_no_index_used. */ 2647 set_statement_no_index_used_t set_statement_no_index_used; 2648 /** @sa set_statement_no_good_index_used. */ 2649 set_statement_no_good_index_used_t set_statement_no_good_index_used; 2650 /** @sa end_statement_v1_t. */ 2651 end_statement_v1_t end_statement; 2652 /** @sa get_thread_transaction_locker_v1_t. */ 2653 get_thread_transaction_locker_v1_t get_thread_transaction_locker; 2654 /** @sa start_transaction_v1_t. */ 2655 start_transaction_v1_t start_transaction; 2656 /** @sa set_transaction_xid_v1_t. */ 2657 set_transaction_xid_v1_t set_transaction_xid; 2658 /** @sa set_transaction_xa_state_v1_t. */ 2659 set_transaction_xa_state_v1_t set_transaction_xa_state; 2660 /** @sa set_transaction_gtid_v1_t. */ 2661 set_transaction_gtid_v1_t set_transaction_gtid; 2662 /** @sa set_transaction_trxid_v1_t. */ 2663 set_transaction_trxid_v1_t set_transaction_trxid; 2664 /** @sa inc_transaction_savepoints_v1_t. */ 2665 inc_transaction_savepoints_v1_t inc_transaction_savepoints; 2666 /** @sa inc_transaction_rollback_to_savepoint_v1_t. */ 2667 inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint; 2668 /** @sa inc_transaction_release_savepoint_v1_t. */ 2669 inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint; 2670 /** @sa end_transaction_v1_t. */ 2671 end_transaction_v1_t end_transaction; 2672 /** @sa start_socket_wait_v1_t. */ 2673 start_socket_wait_v1_t start_socket_wait; 2674 /** @sa end_socket_wait_v1_t. */ 2675 end_socket_wait_v1_t end_socket_wait; 2676 /** @sa set_socket_state_v1_t. */ 2677 set_socket_state_v1_t set_socket_state; 2678 /** @sa set_socket_info_v1_t. */ 2679 set_socket_info_v1_t set_socket_info; 2680 /** @sa set_socket_thread_owner_v1_t. */ 2681 set_socket_thread_owner_v1_t set_socket_thread_owner; 2682 /** @sa create_prepared_stmt_v1_t. */ 2683 create_prepared_stmt_v1_t create_prepared_stmt; 2684 /** @sa destroy_prepared_stmt_v1_t. */ 2685 destroy_prepared_stmt_v1_t destroy_prepared_stmt; 2686 /** @sa reprepare_prepared_stmt_v1_t. */ 2687 reprepare_prepared_stmt_v1_t reprepare_prepared_stmt; 2688 /** @sa execute_prepared_stmt_v1_t. */ 2689 execute_prepared_stmt_v1_t execute_prepared_stmt; 2690 /** @sa set_prepared_stmt_text_v1_t. */ 2691 set_prepared_stmt_text_v1_t set_prepared_stmt_text; 2692 /** @sa digest_start_v1_t. */ 2693 digest_start_v1_t digest_start; 2694 /** @sa digest_end_v1_t. */ 2695 digest_end_v1_t digest_end; 2696 /** @sa set_thread_connect_attrs_v1_t. */ 2697 set_thread_connect_attrs_v1_t set_thread_connect_attrs; 2698 /** @sa start_sp_v1_t. */ 2699 start_sp_v1_t start_sp; 2700 /** @sa start_sp_v1_t. */ 2701 end_sp_v1_t end_sp; 2702 /** @sa drop_sp_v1_t. */ 2703 drop_sp_v1_t drop_sp; 2704 /** @sa get_sp_share_v1_t. */ 2705 get_sp_share_v1_t get_sp_share; 2706 /** @sa release_sp_share_v1_t. */ 2707 release_sp_share_v1_t release_sp_share; 2708 /** @sa register_memory_v1_t. */ 2709 register_memory_v1_t register_memory; 2710 /** @sa memory_alloc_v1_t. */ 2711 memory_alloc_v1_t memory_alloc; 2712 /** @sa memory_realloc_v1_t. */ 2713 memory_realloc_v1_t memory_realloc; 2714 /** @sa memory_claim_v1_t. */ 2715 memory_claim_v1_t memory_claim; 2716 /** @sa memory_free_v1_t. */ 2717 memory_free_v1_t memory_free; 2718 2719 unlock_table_v1_t unlock_table; 2720 2721 create_metadata_lock_v1_t create_metadata_lock; 2722 set_metadata_lock_status_v1_t set_metadata_lock_status; 2723 destroy_metadata_lock_v1_t destroy_metadata_lock; 2724 2725 start_metadata_wait_v1_t start_metadata_wait; 2726 end_metadata_wait_v1_t end_metadata_wait; 2727 }; 2728 2729 /** @} (end of group Group_PSI_v1) */ 2730 2731 #endif /* HAVE_PSI_1 */ 2732 2733 #ifdef USE_PSI_2 2734 #define HAVE_PSI_2 2735 #endif 2736 2737 #ifdef HAVE_PSI_2 2738 2739 /** 2740 @defgroup Group_PSI_v2 Application Binary Interface, version 2 2741 @ingroup Instrumentation_interface 2742 @{ 2743 */ 2744 2745 /** 2746 Performance Schema Interface, version 2. 2747 This is a placeholder, this interface is not defined yet. 2748 @since PSI_VERSION_2 2749 */ 2750 struct PSI_v2 2751 { 2752 /** Placeholder */ 2753 int placeholder; 2754 /* ... extended interface ... */ 2755 }; 2756 2757 /** Placeholder */ 2758 struct PSI_mutex_info_v2 2759 { 2760 /** Placeholder */ 2761 int placeholder; 2762 }; 2763 2764 /** Placeholder */ 2765 struct PSI_rwlock_info_v2 2766 { 2767 /** Placeholder */ 2768 int placeholder; 2769 }; 2770 2771 /** Placeholder */ 2772 struct PSI_cond_info_v2 2773 { 2774 /** Placeholder */ 2775 int placeholder; 2776 }; 2777 2778 /** Placeholder */ 2779 struct PSI_thread_info_v2 2780 { 2781 /** Placeholder */ 2782 int placeholder; 2783 }; 2784 2785 /** Placeholder */ 2786 struct PSI_file_info_v2 2787 { 2788 /** Placeholder */ 2789 int placeholder; 2790 }; 2791 2792 /** Placeholder */ 2793 struct PSI_stage_info_v2 2794 { 2795 /** Placeholder */ 2796 int placeholder; 2797 }; 2798 2799 /** Placeholder */ 2800 struct PSI_statement_info_v2 2801 { 2802 /** Placeholder */ 2803 int placeholder; 2804 }; 2805 2806 /** Placeholder */ 2807 struct PSI_transaction_info_v2 2808 { 2809 /** Placeholder */ 2810 int placeholder; 2811 }; 2812 2813 /** Placeholder */ 2814 struct PSI_idle_locker_state_v2 2815 { 2816 /** Placeholder */ 2817 int placeholder; 2818 }; 2819 2820 /** Placeholder */ 2821 struct PSI_mutex_locker_state_v2 2822 { 2823 /** Placeholder */ 2824 int placeholder; 2825 }; 2826 2827 /** Placeholder */ 2828 struct PSI_rwlock_locker_state_v2 2829 { 2830 /** Placeholder */ 2831 int placeholder; 2832 }; 2833 2834 /** Placeholder */ 2835 struct PSI_cond_locker_state_v2 2836 { 2837 /** Placeholder */ 2838 int placeholder; 2839 }; 2840 2841 /** Placeholder */ 2842 struct PSI_file_locker_state_v2 2843 { 2844 /** Placeholder */ 2845 int placeholder; 2846 }; 2847 2848 /** Placeholder */ 2849 struct PSI_statement_locker_state_v2 2850 { 2851 /** Placeholder */ 2852 int placeholder; 2853 }; 2854 2855 /** Placeholder */ 2856 struct PSI_transaction_locker_state_v2 2857 { 2858 /** Placeholder */ 2859 int placeholder; 2860 }; 2861 2862 /** Placeholder */ 2863 struct PSI_socket_locker_state_v2 2864 { 2865 /** Placeholder */ 2866 int placeholder; 2867 }; 2868 2869 struct PSI_metadata_locker_state_v2 2870 { 2871 int placeholder; 2872 }; 2873 2874 /** @} (end of group Group_PSI_v2) */ 2875 2876 #endif /* HAVE_PSI_2 */ 2877 2878 /** 2879 @typedef PSI 2880 The instrumentation interface for the current version. 2881 @sa PSI_CURRENT_VERSION 2882 */ 2883 2884 /** 2885 @typedef PSI_mutex_info 2886 The mutex information structure for the current version. 2887 */ 2888 2889 /** 2890 @typedef PSI_rwlock_info 2891 The rwlock information structure for the current version. 2892 */ 2893 2894 /** 2895 @typedef PSI_cond_info 2896 The cond information structure for the current version. 2897 */ 2898 2899 /** 2900 @typedef PSI_thread_info 2901 The thread information structure for the current version. 2902 */ 2903 2904 /** 2905 @typedef PSI_file_info 2906 The file information structure for the current version. 2907 */ 2908 2909 /* Export the required version */ 2910 #ifdef USE_PSI_1 2911 typedef struct PSI_v1 PSI; 2912 typedef struct PSI_mutex_info_v1 PSI_mutex_info; 2913 typedef struct PSI_rwlock_info_v1 PSI_rwlock_info; 2914 typedef struct PSI_cond_info_v1 PSI_cond_info; 2915 typedef struct PSI_thread_info_v1 PSI_thread_info; 2916 typedef struct PSI_file_info_v1 PSI_file_info; 2917 typedef struct PSI_stage_info_v1 PSI_stage_info; 2918 typedef struct PSI_statement_info_v1 PSI_statement_info; 2919 typedef struct PSI_transaction_info_v1 PSI_transaction_info; 2920 typedef struct PSI_socket_info_v1 PSI_socket_info; 2921 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state; 2922 typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state; 2923 typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state; 2924 typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state; 2925 typedef struct PSI_file_locker_state_v1 PSI_file_locker_state; 2926 typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state; 2927 typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state; 2928 typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state; 2929 typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state; 2930 typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state; 2931 #endif 2932 2933 #ifdef USE_PSI_2 2934 typedef struct PSI_v2 PSI; 2935 typedef struct PSI_mutex_info_v2 PSI_mutex_info; 2936 typedef struct PSI_rwlock_info_v2 PSI_rwlock_info; 2937 typedef struct PSI_cond_info_v2 PSI_cond_info; 2938 typedef struct PSI_thread_info_v2 PSI_thread_info; 2939 typedef struct PSI_file_info_v2 PSI_file_info; 2940 typedef struct PSI_stage_info_v2 PSI_stage_info; 2941 typedef struct PSI_statement_info_v2 PSI_statement_info; 2942 typedef struct PSI_transaction_info_v2 PSI_transaction_info; 2943 typedef struct PSI_socket_info_v2 PSI_socket_info; 2944 typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state; 2945 typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state; 2946 typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state; 2947 typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state; 2948 typedef struct PSI_file_locker_state_v2 PSI_file_locker_state; 2949 typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state; 2950 typedef struct PSI_transaction_locker_state_v2 PSI_transaction_locker_state; 2951 typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state; 2952 typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state; 2953 typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state; 2954 #endif 2955 2956 #else /* HAVE_PSI_INTERFACE */ 2957 2958 /** 2959 Dummy structure, used to declare PSI_server when no instrumentation 2960 is available. 2961 The content does not matter, since PSI_server will be NULL. 2962 */ 2963 struct PSI_none 2964 { 2965 int opaque; 2966 }; 2967 typedef struct PSI_none PSI; 2968 2969 /** 2970 Stage instrument information. 2971 @since PSI_VERSION_1 2972 This structure is used to register an instrumented stage. 2973 */ 2974 struct PSI_stage_info_none 2975 { 2976 /** Unused stage key. */ 2977 unsigned int m_key; 2978 /** The name of the stage instrument. */ 2979 const char *m_name; 2980 /** Unused stage flags. */ 2981 int m_flags; 2982 }; 2983 2984 /** 2985 The stage instrumentation has to co exist with the legacy 2986 THD::set_proc_info instrumentation. 2987 To avoid duplication of the instrumentation in the server, 2988 the common PSI_stage_info structure is used, 2989 so we export it here, even when not building 2990 with HAVE_PSI_INTERFACE. 2991 */ 2992 typedef struct PSI_stage_info_none PSI_stage_info; 2993 2994 #endif /* HAVE_PSI_INTERFACE */ 2995 2996 extern MYSQL_PLUGIN_IMPORT PSI *PSI_server; 2997 2998 /* 2999 Allow to override PSI_XXX_CALL at compile time 3000 with more efficient implementations, if available. 3001 If nothing better is available, 3002 make a dynamic call using the PSI_server function pointer. 3003 */ 3004 3005 #define PSI_DYNAMIC_CALL(M) PSI_server->M 3006 3007 /** @} */ 3008 3009 C_MODE_END 3010 #endif /* MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H */ 3011 3012