Skip to content

Commit

Permalink
MroongaSE: addint thd_autoinc and thd_error_context plugin services
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Dec 12, 2013
1 parent 67f5143 commit 1345a75
Show file tree
Hide file tree
Showing 22 changed files with 345 additions and 36 deletions.
12 changes: 8 additions & 4 deletions include/mysql/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
26 changes: 25 additions & 1 deletion include/mysql/plugin_audit.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@
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;
Expand Down Expand Up @@ -280,7 +305,6 @@
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);
Expand Down
26 changes: 25 additions & 1 deletion include/mysql/plugin_auth.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@
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;
Expand Down Expand Up @@ -280,7 +305,6 @@
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);
Expand Down
26 changes: 25 additions & 1 deletion include/mysql/plugin_ftparser.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@
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;
Expand Down Expand Up @@ -233,7 +258,6 @@
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);
Expand Down
53 changes: 53 additions & 0 deletions include/mysql/service_thd_autoinc.h
Original file line number Diff line number Diff line change
@@ -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
93 changes: 93 additions & 0 deletions include/mysql/service_thd_error_context.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions include/mysql/services.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion include/service_versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
#define VERSION_thd_timezone 0x0100
#define VERSION_my_sha1 0x0100
#define VERSION_logger 0x0100

#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
2 changes: 2 additions & 0 deletions libservices/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ SET(MYSQLSERVICES_SOURCES
thd_alloc_service.c
thd_wait_service.c
thd_timezone_service.c
thd_autoinc_service.c
thd_error_context_service.c
progress_report_service.c
debug_sync_service.c
my_sha1_service.c
Expand Down
18 changes: 18 additions & 0 deletions libservices/thd_autoinc_service.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright (C) 2013 MariaDB Foundation
Use is subject to license terms.
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 */

#include <service_versions.h>
SERVICE_VERSION thd_autoinc_service= (void *) VERSION_thd_autoinc;
18 changes: 18 additions & 0 deletions libservices/thd_error_context_service.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright (C) 2013 MariaDB Foundation
Use is subject to license terms.
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 */

#include <service_versions.h>
SERVICE_VERSION thd_error_context_service= (void *) VERSION_thd_error_context;
2 changes: 1 addition & 1 deletion mysql-test/r/handlersocket.result
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugin_version 1.0
plugin_status ACTIVE
plugin_type DAEMON
plugin_library handlersocket.so
plugin_library_version 1.7
plugin_library_version 1.8
plugin_author higuchi dot akira at dena dot jp
plugin_description Direct access into InnoDB
plugin_license BSD
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/r/plugin.result
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE STORAGE ENGINE
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
PLUGIN_LIBRARY_VERSION 1.7
PLUGIN_LIBRARY_VERSION 1.8
PLUGIN_AUTHOR Brian Aker, MySQL AB
PLUGIN_DESCRIPTION Example storage engine
PLUGIN_LICENSE GPL
Expand All @@ -28,7 +28,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE DAEMON
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
PLUGIN_LIBRARY_VERSION 1.7
PLUGIN_LIBRARY_VERSION 1.8
PLUGIN_AUTHOR Sergei Golubchik
PLUGIN_DESCRIPTION Unusable Daemon
PLUGIN_LICENSE GPL
Expand Down Expand Up @@ -62,7 +62,7 @@ PLUGIN_STATUS DELETED
PLUGIN_TYPE STORAGE ENGINE
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
PLUGIN_LIBRARY_VERSION 1.7
PLUGIN_LIBRARY_VERSION 1.8
PLUGIN_AUTHOR Brian Aker, MySQL AB
PLUGIN_DESCRIPTION Example storage engine
PLUGIN_LICENSE GPL
Expand Down

0 comments on commit 1345a75

Please sign in to comment.