service_thd_error_context.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef MYSQL_SERVICE_THD_STMT_DA_INCLUDED
  2. /* Copyright (C) 2013 MariaDB Foundation.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /**
  14. @file
  15. This service provides access to the statement diagnostics area:
  16. - error message
  17. - error number
  18. - row for warning (e.g. for multi-row INSERT statements)
  19. */
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. extern struct thd_error_context_service_st {
  24. const char *(*thd_get_error_message_func)(const MYSQL_THD thd);
  25. unsigned int (*thd_get_error_number_func)(const MYSQL_THD thd);
  26. unsigned long (*thd_get_error_row_func)(const MYSQL_THD thd);
  27. void (*thd_inc_error_row_func)(MYSQL_THD thd);
  28. char *(*thd_get_error_context_description_func)(MYSQL_THD thd,
  29. char *buffer,
  30. unsigned int length,
  31. unsigned int max_query_length);
  32. } *thd_error_context_service;
  33. #ifdef MYSQL_DYNAMIC_PLUGIN
  34. #define thd_get_error_message(thd) \
  35. (thd_error_context_service->thd_get_error_message_func((thd)))
  36. #define thd_get_error_number(thd) \
  37. (thd_error_context_service->thd_get_error_number_func((thd)))
  38. #define thd_get_error_row(thd) \
  39. (thd_error_context_service->thd_get_error_row_func((thd)))
  40. #define thd_inc_error_row(thd) \
  41. (thd_error_context_service->thd_inc_error_row_func((thd)))
  42. #define thd_get_error_context_description(thd, buffer, length, max_query_len) \
  43. (thd_error_context_service->thd_get_error_context_description_func((thd), \
  44. (buffer), \
  45. (length), \
  46. (max_query_len)))
  47. #else
  48. /**
  49. Return error message
  50. @param thd user thread connection handle
  51. @return error text
  52. */
  53. const char *thd_get_error_message(const MYSQL_THD thd);
  54. /**
  55. Return error number
  56. @param thd user thread connection handle
  57. @return error number
  58. */
  59. unsigned int thd_get_error_number(const MYSQL_THD thd);
  60. /**
  61. Return the current row number (i.e. in a multiple INSERT statement)
  62. @param thd user thread connection handle
  63. @return row number
  64. */
  65. unsigned long thd_get_error_row(const MYSQL_THD thd);
  66. /**
  67. Increment the current row number
  68. @param thd user thread connection handle
  69. */
  70. void thd_inc_error_row(MYSQL_THD thd);
  71. /**
  72. Return a text description of a thread, its security context (user,host)
  73. and the current query.
  74. */
  75. char *thd_get_error_context_description(MYSQL_THD thd,
  76. char *buffer, unsigned int length,
  77. unsigned int max_query_length);
  78. #endif
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #define MYSQL_SERVICE_THD_STMT_DA_INCLUDED
  83. #endif