mysql_sp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. #ifndef MYSQL_SP_H
  19. #define MYSQL_SP_H
  20. /**
  21. @file mysql/psi/mysql_sp.h
  22. Instrumentation helpers for stored programs.
  23. */
  24. #include "mysql/psi/psi.h"
  25. #ifndef PSI_SP_CALL
  26. #define PSI_SP_CALL(M) PSI_DYNAMIC_CALL(M)
  27. #endif
  28. #ifdef HAVE_PSI_SP_INTERFACE
  29. #define MYSQL_START_SP(STATE, SP_SHARE) \
  30. inline_mysql_start_sp(STATE, SP_SHARE)
  31. #else
  32. #define MYSQL_START_SP(STATE, SP_SHARE) \
  33. NULL
  34. #endif
  35. #ifdef HAVE_PSI_SP_INTERFACE
  36. #define MYSQL_END_SP(LOCKER) \
  37. inline_mysql_end_sp(LOCKER)
  38. #else
  39. #define MYSQL_END_SP(LOCKER) \
  40. do {} while (0)
  41. #endif
  42. #ifdef HAVE_PSI_SP_INTERFACE
  43. #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
  44. inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
  45. #else
  46. #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
  47. do {} while (0)
  48. #endif
  49. #ifdef HAVE_PSI_SP_INTERFACE
  50. #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
  51. inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
  52. #else
  53. #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
  54. NULL
  55. #endif
  56. #ifdef HAVE_PSI_SP_INTERFACE
  57. static inline struct PSI_sp_locker*
  58. inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
  59. {
  60. return PSI_SP_CALL(start_sp)(state, sp_share);
  61. }
  62. static inline void inline_mysql_end_sp(PSI_sp_locker *locker)
  63. {
  64. if (likely(locker != NULL))
  65. PSI_SP_CALL(end_sp)(locker);
  66. }
  67. static inline void
  68. inline_mysql_drop_sp(uint sp_type,
  69. const char* schema_name, uint shcema_name_length,
  70. const char* object_name, uint object_name_length)
  71. {
  72. PSI_SP_CALL(drop_sp)(sp_type,
  73. schema_name, shcema_name_length,
  74. object_name, object_name_length);
  75. }
  76. static inline PSI_sp_share*
  77. inline_mysql_get_sp_share(uint sp_type,
  78. const char* schema_name, uint shcema_name_length,
  79. const char* object_name, uint object_name_length)
  80. {
  81. return PSI_SP_CALL(get_sp_share)(sp_type,
  82. schema_name, shcema_name_length,
  83. object_name, object_name_length);
  84. }
  85. #endif
  86. #endif