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