1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MroongaSE: addint thd_autoinc and thd_error_context plugin services

This commit is contained in:
Alexander Barkov
2013-12-12 19:18:49 +04:00
parent 67f514382b
commit 1345a75922
22 changed files with 345 additions and 36 deletions

View File

@@ -75,7 +75,7 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104
/* MariaDB plugin interface version */
#define MARIA_PLUGIN_INTERFACE_VERSION 0x0107
#define MARIA_PLUGIN_INTERFACE_VERSION 0x0108
/*
The allowable types of plugins
@@ -622,11 +622,15 @@ void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
void thd_storage_lock_wait(MYSQL_THD thd, long long value);
int thd_tx_isolation(const MYSQL_THD thd);
int thd_tx_is_read_only(const MYSQL_THD thd);
#if MARIA_PLUGIN_INTERFACE_VERSION < 0x0200
/**
TODO: This function is for API compatibility, remove it eventually.
All engines should switch to use thd_get_error_context_description()
plugin service function.
*/
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
unsigned int max_query_len);
/* Increments the row counter, see THD::row_count */
void thd_inc_row_count(MYSQL_THD thd);
#endif
/**
Create a temporary file.

View File

@@ -137,6 +137,31 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
#include <mysql/service_thd_autoinc.h>
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
#include <mysql/service_thd_error_context.h>
extern struct thd_error_context_service_st {
const char *(*thd_get_error_message_func)(const void* thd);
unsigned int (*thd_get_error_number_func)(const void* thd);
unsigned long (*thd_get_error_row_func)(const void* thd);
void (*thd_inc_error_row_func)(void* thd);
char *(*thd_get_error_context_description_func)(void* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
const char *thd_get_error_message(const void* thd);
unsigned int thd_get_error_number(const void* thd);
unsigned long thd_get_error_row(const void* thd);
void thd_inc_error_row(void* thd);
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -280,7 +305,6 @@ int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
char *thd_security_context(void* thd, char *buffer, unsigned int length,
unsigned int max_query_len);
void thd_inc_row_count(void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);

View File

@@ -137,6 +137,31 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
#include <mysql/service_thd_autoinc.h>
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
#include <mysql/service_thd_error_context.h>
extern struct thd_error_context_service_st {
const char *(*thd_get_error_message_func)(const void* thd);
unsigned int (*thd_get_error_number_func)(const void* thd);
unsigned long (*thd_get_error_row_func)(const void* thd);
void (*thd_inc_error_row_func)(void* thd);
char *(*thd_get_error_context_description_func)(void* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
const char *thd_get_error_message(const void* thd);
unsigned int thd_get_error_number(const void* thd);
unsigned long thd_get_error_row(const void* thd);
void thd_inc_error_row(void* thd);
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -280,7 +305,6 @@ int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
char *thd_security_context(void* thd, char *buffer, unsigned int length,
unsigned int max_query_len);
void thd_inc_row_count(void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);

View File

@@ -137,6 +137,31 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
#include <mysql/service_thd_autoinc.h>
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
#include <mysql/service_thd_error_context.h>
extern struct thd_error_context_service_st {
const char *(*thd_get_error_message_func)(const void* thd);
unsigned int (*thd_get_error_number_func)(const void* thd);
unsigned long (*thd_get_error_row_func)(const void* thd);
void (*thd_inc_error_row_func)(void* thd);
char *(*thd_get_error_context_description_func)(void* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
const char *thd_get_error_message(const void* thd);
unsigned int thd_get_error_number(const void* thd);
unsigned long thd_get_error_row(const void* thd);
void thd_inc_error_row(void* thd);
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -233,7 +258,6 @@ int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
char *thd_security_context(void* thd, char *buffer, unsigned int length,
unsigned int max_query_len);
void thd_inc_row_count(void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);

View File

@@ -0,0 +1,53 @@
#ifndef MYSQL_SERVICE_THD_AUTOINC_INCLUDED
/* Copyright (C) 2013 MariaDB Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/**
@file
This service provides access to the auto_increment related system variables:
@@auto_increment_offset
@@auto_increment_increment
*/
#ifdef __cplusplus
extern "C" {
#endif
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const MYSQL_THD thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
#define thd_get_autoinc(thd, off, inc) \
(thd_autoinc_service->thd_get_autoinc_func((thd), (off), (inc)))
#else
/**
Return autoincrement system variables
@param IN thd user thread connection handle
@param OUT off the value of @@SESSION.auto_increment_offset
@param OUT inc the value of @@SESSION.auto_increment_increment
*/
void thd_get_autoinc(const MYSQL_THD thd,
unsigned long* off, unsigned long* inc);
#endif
#ifdef __cplusplus
}
#endif
#define MYSQL_SERVICE_THD_AUTOINC_INCLUDED
#endif

View File

@@ -0,0 +1,93 @@
#ifndef MYSQL_SERVICE_THD_STMT_DA_INCLUDED
/* Copyright (C) 2013 MariaDB Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/**
@file
This service provides access to the statement diagnostics area:
- error message
- error number
- row for warning (e.g. for multi-row INSERT statements)
*/
#ifdef __cplusplus
extern "C" {
#endif
extern struct thd_error_context_service_st {
const char *(*thd_get_error_message_func)(const MYSQL_THD thd);
unsigned int (*thd_get_error_number_func)(const MYSQL_THD thd);
unsigned long (*thd_get_error_row_func)(const MYSQL_THD thd);
void (*thd_inc_error_row_func)(MYSQL_THD thd);
char *(*thd_get_error_context_description_func)(MYSQL_THD thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
#define thd_get_error_message(thd) \
(thd_error_context_service->thd_get_error_message_func((thd)))
#define thd_get_error_number(thd) \
(thd_error_context_service->thd_get_error_number_func((thd)))
#define thd_get_error_row(thd) \
(thd_error_context_service->thd_get_error_row_func((thd)))
#define thd_inc_error_row(thd) \
(thd_error_context_service->thd_inc_error_row_func((thd)))
#define thd_get_error_context_description(thd, buffer, length, max_query_len) \
(thd_error_context_service->thd_get_error_context_description_func((thd), \
(buffer), \
(length), \
(max_query_len)))
#else
/**
Return error message
@param thd user thread connection handle
@return error text
*/
const char *thd_get_error_message(const MYSQL_THD thd);
/**
Return error number
@param thd user thread connection handle
@return error number
*/
unsigned int thd_get_error_number(const MYSQL_THD thd);
/**
Return the current row number (i.e. in a multiple INSERT statement)
@param thd user thread connection handle
@return row number
*/
unsigned long thd_get_error_row(const MYSQL_THD thd);
/**
Increment the current row number
@param thd user thread connection handle
*/
void thd_inc_error_row(MYSQL_THD thd);
/**
Return a text description of a thread, its security context (user,host)
and the current query.
*/
char *thd_get_error_context_description(MYSQL_THD thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
#endif
#ifdef __cplusplus
}
#endif
#define MYSQL_SERVICE_THD_STMT_DA_INCLUDED
#endif

View File

@@ -28,6 +28,8 @@ extern "C" {
#include <mysql/service_thd_timezone.h>
#include <mysql/service_sha1.h>
#include <mysql/service_logger.h>
#include <mysql/service_thd_autoinc.h>
#include <mysql/service_thd_error_context.h>
#ifdef __cplusplus
}