summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-10-04 18:33:09 +0400
committerAlexander Barkov <bar@mariadb.com>2019-10-04 18:33:09 +0400
commit61284bc7b782c38266f4f93a4fd0f05f95949f73 (patch)
treed469a3f4311d79e26301bf1248ed544c99c607e9
parent57ce0bab3242dfc709ab051cc96d991586021e5f (diff)
downloadmariadb-git-bb-10.5-bar-m20016.tar.gz
MDEV-20016 Add MariaDB_DATA_TYPE_PLUGINbb-10.5-bar-m20016
-rw-r--r--cmake/abi_check.cmake1
-rw-r--r--include/mysql/plugin.h3
-rw-r--r--include/mysql/plugin_data_type.h49
-rw-r--r--include/mysql/plugin_data_type.h.pp629
-rw-r--r--plugin/type_test/CMakeLists.txt17
-rw-r--r--plugin/type_test/mysql-test/type_test/suite.opt1
-rw-r--r--plugin/type_test/mysql-test/type_test/suite.pm10
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_double-debug.result35
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_double-debug.test30
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_double.result691
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_double.test512
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_int8-debug.result35
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_int8-debug.test30
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_int8.result670
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_int8.test500
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_mysql.result27
-rw-r--r--plugin/type_test/mysql-test/type_test/type_test_mysql.test6
-rw-r--r--plugin/type_test/plugin.cc343
-rw-r--r--sql/sql_lex.cc7
-rw-r--r--sql/sql_plugin.cc15
-rw-r--r--sql/sql_type.cc23
-rw-r--r--sql/sql_type.h5
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--sql/sql_yacc_ora.yy2
-rw-r--r--sql/table.cc3
25 files changed, 3628 insertions, 18 deletions
diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake
index 805322229c4..4c7735d75e7 100644
--- a/cmake/abi_check.cmake
+++ b/cmake/abi_check.cmake
@@ -45,6 +45,7 @@ IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND RUN_ABI_CHECK)
${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
${CMAKE_SOURCE_DIR}/include/mysql/plugin_password_validation.h
${CMAKE_SOURCE_DIR}/include/mysql/plugin_encryption.h
+ ${CMAKE_SOURCE_DIR}/include/mysql/plugin_data_type.h
)
ADD_CUSTOM_TARGET(abi_check ALL
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 85e52a247af..c13b82320e3 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -90,11 +90,12 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_AUDIT_PLUGIN 5
#define MYSQL_REPLICATION_PLUGIN 6
#define MYSQL_AUTHENTICATION_PLUGIN 7
-#define MYSQL_MAX_PLUGIN_TYPE_NUM 10 /* The number of plugin types */
+#define MYSQL_MAX_PLUGIN_TYPE_NUM 11 /* The number of plugin types */
/* MariaDB plugin types */
#define MariaDB_PASSWORD_VALIDATION_PLUGIN 8
#define MariaDB_ENCRYPTION_PLUGIN 9
+#define MariaDB_DATA_TYPE_PLUGIN 10
/* We use the following strings to define licenses for plugins */
#define PLUGIN_LICENSE_PROPRIETARY 0
diff --git a/include/mysql/plugin_data_type.h b/include/mysql/plugin_data_type.h
new file mode 100644
index 00000000000..4f2235c6a38
--- /dev/null
+++ b/include/mysql/plugin_data_type.h
@@ -0,0 +1,49 @@
+#ifndef MARIADB_PLUGIN_DATA_TYPE_INCLUDED
+#define MARIADB_PLUGIN_DATA_TYPE_INCLUDED
+/* Copyright (C) 2019, Alexander Barkov and MariaDB
+
+ 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-1335 USA */
+
+/**
+ @file
+
+ Data Type Plugin API.
+
+ This file defines the API for server plugins that manage data types.
+*/
+
+#ifdef __cplusplus
+
+#include <mysql/plugin.h>
+
+/*
+ API for data type plugins. (MariaDB_DATA_TYPE_PLUGIN)
+*/
+#define MariaDB_DATA_TYPE_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
+
+
+struct st_mariadb_data_type
+{
+ int interface_version;
+ const class Type_handler *type_handler;
+};
+
+
+/**
+ Data type plugin descriptor
+*/
+
+#endif /* __cplusplus */
+
+#endif /* MARIADB_PLUGIN_DATA_TYPE_INCLUDED */
diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp
new file mode 100644
index 00000000000..a1a9c917efe
--- /dev/null
+++ b/include/mysql/plugin_data_type.h.pp
@@ -0,0 +1,629 @@
+class THD;
+class Item;
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
+extern struct base64_service_st {
+ int (*base64_needed_encoded_length_ptr)(int length_of_data);
+ int (*base64_encode_max_arg_length_ptr)(void);
+ int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
+ int (*base64_decode_max_arg_length_ptr)();
+ int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
+ int (*base64_decode_ptr)(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+} *base64_service;
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
+struct encryption_service_st {
+ unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
+ unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
+ unsigned char* buffer, unsigned int* length);
+ unsigned int (*encryption_ctx_size_func)(unsigned int key_id, unsigned int key_version);
+ int (*encryption_ctx_init_func)(void *ctx, const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen,
+ int flags, unsigned int key_id,
+ unsigned int key_version);
+ int (*encryption_ctx_update_func)(void *ctx, const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen);
+ int (*encryption_ctx_finish_func)(void *ctx, unsigned char* dst, unsigned int* dlen);
+ unsigned int (*encryption_encrypted_length_func)(unsigned int slen, unsigned int key_id, unsigned int key_version);
+};
+extern struct encryption_service_st encryption_handler;
+static inline unsigned int encryption_key_id_exists(unsigned int id)
+{
+ return encryption_handler.encryption_key_get_latest_version_func(id) != (~(unsigned int)0);
+}
+static inline unsigned int encryption_key_version_exists(unsigned int id, unsigned int version)
+{
+ unsigned int unused;
+ return encryption_handler.encryption_key_get_func((id),(version),(NULL),(&unused)) != (~(unsigned int)0);
+}
+static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen,
+ int flags, unsigned int key_id, unsigned int key_version)
+{
+ void *ctx= alloca(encryption_handler.encryption_ctx_size_func((key_id),(key_version)));
+ int res1, res2;
+ unsigned int d1, d2;
+ if ((res1= encryption_handler.encryption_ctx_init_func((ctx),(key),(klen),(iv),(ivlen),(flags),(key_id),(key_version))))
+ return res1;
+ res1= encryption_handler.encryption_ctx_update_func((ctx),(src),(slen),(dst),(&d1));
+ res2= encryption_handler.encryption_ctx_finish_func((ctx),(dst + d1),(&d2));
+ *dlen= d1 + d2;
+ return res1 ? res1 : res2;
+}
+}
+extern "C" {
+struct st_encryption_scheme_key {
+ unsigned int version;
+ unsigned char key[16];
+};
+struct st_encryption_scheme {
+ unsigned char iv[16];
+ struct st_encryption_scheme_key key[3];
+ unsigned int keyserver_requests;
+ unsigned int key_id;
+ unsigned int type;
+ void (*locker)(struct st_encryption_scheme *self, int release);
+};
+extern struct encryption_scheme_service_st {
+ int (*encryption_scheme_encrypt_func)
+ (const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+ int (*encryption_scheme_decrypt_func)
+ (const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+} *encryption_scheme_service;
+int encryption_scheme_encrypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
+enum thd_kill_levels {
+ THD_IS_NOT_KILLED=0,
+ THD_ABORT_SOFTLY=50,
+ THD_ABORT_ASAP=100,
+};
+extern struct kill_statement_service_st {
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
+typedef struct logger_handle_st LOGGER_HANDLE;
+extern struct logger_service_st {
+ void (*logger_init_mutexes)();
+ LOGGER_HANDLE* (*open)(const char *path,
+ unsigned long long size_limit,
+ unsigned int rotations);
+ int (*close)(LOGGER_HANDLE *log);
+ int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
+ int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
+ int (*write)(LOGGER_HANDLE *log, const char *buffer, size_t size);
+ int (*rotate)(LOGGER_HANDLE *log);
+} *logger_service;
+ void logger_init_mutexes();
+ LOGGER_HANDLE *logger_open(const char *path,
+ unsigned long long size_limit,
+ unsigned int rotations);
+ int logger_close(LOGGER_HANDLE *log);
+ int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
+ 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);
+}
+extern "C" {
+extern struct my_md5_service_st {
+ void (*my_md5_type)(unsigned char*, const char*, size_t);
+ void (*my_md5_multi_type)(unsigned char*, ...);
+ size_t (*my_md5_context_size_type)();
+ void (*my_md5_init_type)(void *);
+ void (*my_md5_input_type)(void *, const unsigned char *, size_t);
+ void (*my_md5_result_type)(void *, unsigned char *);
+} *my_md5_service;
+void my_md5(unsigned char*, const char*, size_t);
+void my_md5_multi(unsigned char*, ...);
+size_t my_md5_context_size();
+void my_md5_init(void *context);
+void my_md5_input(void *context, const unsigned char *buf, size_t len);
+void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
+enum my_aes_mode {
+ MY_AES_ECB, MY_AES_CBC
+};
+extern struct my_crypt_service_st {
+ int (*my_aes_crypt_init)(void *ctx, enum my_aes_mode mode, int flags,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen);
+ int (*my_aes_crypt_update)(void *ctx, const unsigned char *src, unsigned int slen,
+ unsigned char *dst, unsigned int *dlen);
+ int (*my_aes_crypt_finish)(void *ctx, unsigned char *dst, unsigned int *dlen);
+ int (*my_aes_crypt)(enum my_aes_mode mode, int flags,
+ const unsigned char *src, unsigned int slen, unsigned char *dst, unsigned int *dlen,
+ const unsigned char *key, unsigned int klen, const unsigned char *iv, unsigned int ivlen);
+ unsigned int (*my_aes_get_size)(enum my_aes_mode mode, unsigned int source_length);
+ unsigned int (*my_aes_ctx_size)(enum my_aes_mode mode);
+ int (*my_random_bytes)(unsigned char* buf, int num);
+} *my_crypt_service;
+int my_aes_crypt_init(void *ctx, enum my_aes_mode mode, int flags,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen);
+int my_aes_crypt_update(void *ctx, const unsigned char *src, unsigned int slen,
+ unsigned char *dst, unsigned int *dlen);
+int my_aes_crypt_finish(void *ctx, unsigned char *dst, unsigned int *dlen);
+int my_aes_crypt(enum my_aes_mode mode, int flags,
+ const unsigned char *src, unsigned int slen, unsigned char *dst, unsigned int *dlen,
+ const unsigned char *key, unsigned int klen, const unsigned char *iv, unsigned int ivlen);
+int my_random_bytes(unsigned char* buf, int num);
+unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
+unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
+extern struct my_print_error_service_st {
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+} *my_print_error_service;
+extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
+extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
+extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
+extern struct my_snprintf_service_st {
+ size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
+ size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
+} *my_snprintf_service;
+size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
+size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
+extern struct progress_report_service_st {
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
+ unsigned long long progress,
+ unsigned long long max_progress);
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
+ const char *func,
+ const char *file,
+ unsigned int line);
+} *progress_report_service;
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
+ unsigned long long progress,
+ unsigned long long max_progress);
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
+ const char *file, unsigned int line);
+}
+extern "C" {
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+ size_t (*my_sha1_context_size_type)();
+ void (*my_sha1_init_type)(void *);
+ void (*my_sha1_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha1_result_type)(void *, unsigned char *);
+} *my_sha1_service;
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
+size_t my_sha1_context_size();
+void my_sha1_init(void *context);
+void my_sha1_input(void *context, const unsigned char *buf, size_t len);
+void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
+extern struct my_sha2_service_st {
+ void (*my_sha224_type)(unsigned char*, const char*, size_t);
+ void (*my_sha224_multi_type)(unsigned char*, ...);
+ size_t (*my_sha224_context_size_type)();
+ void (*my_sha224_init_type)(void *);
+ void (*my_sha224_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha224_result_type)(void *, unsigned char *);
+ void (*my_sha256_type)(unsigned char*, const char*, size_t);
+ void (*my_sha256_multi_type)(unsigned char*, ...);
+ size_t (*my_sha256_context_size_type)();
+ void (*my_sha256_init_type)(void *);
+ void (*my_sha256_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha256_result_type)(void *, unsigned char *);
+ void (*my_sha384_type)(unsigned char*, const char*, size_t);
+ void (*my_sha384_multi_type)(unsigned char*, ...);
+ size_t (*my_sha384_context_size_type)();
+ void (*my_sha384_init_type)(void *);
+ void (*my_sha384_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha384_result_type)(void *, unsigned char *);
+ void (*my_sha512_type)(unsigned char*, const char*, size_t);
+ void (*my_sha512_multi_type)(unsigned char*, ...);
+ size_t (*my_sha512_context_size_type)();
+ void (*my_sha512_init_type)(void *);
+ void (*my_sha512_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha512_result_type)(void *, unsigned char *);
+} *my_sha2_service;
+void my_sha224(unsigned char*, const char*, size_t);
+void my_sha224_multi(unsigned char*, ...);
+size_t my_sha224_context_size();
+void my_sha224_init(void *context);
+void my_sha224_input(void *context, const unsigned char *buf, size_t len);
+void my_sha224_result(void *context, unsigned char *digest);
+void my_sha256(unsigned char*, const char*, size_t);
+void my_sha256_multi(unsigned char*, ...);
+size_t my_sha256_context_size();
+void my_sha256_init(void *context);
+void my_sha256_input(void *context, const unsigned char *buf, size_t len);
+void my_sha256_result(void *context, unsigned char *digest);
+void my_sha384(unsigned char*, const char*, size_t);
+void my_sha384_multi(unsigned char*, ...);
+size_t my_sha384_context_size();
+void my_sha384_init(void *context);
+void my_sha384_input(void *context, const unsigned char *buf, size_t len);
+void my_sha384_result(void *context, unsigned char *digest);
+void my_sha512(unsigned char*, const char*, size_t);
+void my_sha512_multi(unsigned char*, ...);
+size_t my_sha512_context_size();
+void my_sha512_init(void *context);
+void my_sha512_input(void *context, const unsigned char *buf, size_t len);
+void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
+ MYSQL_CONST_LEX_STRING *,
+ const char *, size_t, int);
+} *thd_alloc_service;
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
+}
+extern "C" {
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const THD* thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+void thd_get_autoinc(const THD* thd,
+ unsigned long* off, unsigned long* inc);
+}
+extern "C" {
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
+}
+extern "C" {
+extern struct thd_rnd_service_st {
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
+} *thd_rnd_service;
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
+typedef int MYSQL_THD_KEY_T;
+extern struct thd_specifics_service_st {
+ int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
+ void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
+} *thd_specifics_service;
+int thd_key_create(MYSQL_THD_KEY_T *key);
+void thd_key_delete(MYSQL_THD_KEY_T *key);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern "C" {
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
+typedef enum _thd_wait_type_e {
+ THD_WAIT_SLEEP= 1,
+ THD_WAIT_DISKIO= 2,
+ THD_WAIT_ROW_LOCK= 3,
+ THD_WAIT_GLOBAL_LOCK= 4,
+ THD_WAIT_META_DATA_LOCK= 5,
+ THD_WAIT_TABLE_LOCK= 6,
+ THD_WAIT_USER_LOCK= 7,
+ THD_WAIT_BINLOG= 8,
+ THD_WAIT_GROUP_COMMIT= 9,
+ THD_WAIT_SYNC= 10,
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
+} thd_wait_type;
+extern struct thd_wait_service_st {
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
+} *thd_wait_service;
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
+enum json_types
+{
+ JSV_BAD_JSON=-1,
+ JSV_NOTHING=0,
+ JSV_OBJECT=1,
+ JSV_ARRAY=2,
+ JSV_STRING=3,
+ JSV_NUMBER=4,
+ JSV_TRUE=5,
+ JSV_FALSE=6,
+ JSV_NULL=7
+};
+extern struct json_service_st {
+ enum json_types (*json_type)(const char *js, const char *js_end,
+ const char **value, int *value_len);
+ enum json_types (*json_get_array_item)(const char *js, const char *js_end,
+ int n_item,
+ const char **value, int *value_len);
+ enum json_types (*json_get_object_key)(const char *js, const char *js_end,
+ const char *key,
+ const char **value, int *value_len);
+ enum json_types (*json_get_object_nkey)(const char *js,const char *js_end,
+ int nkey,
+ const char **keyname, const char **keyname_end,
+ const char **value, int *value_len);
+ int (*json_escape_string)(const char *str,const char *str_end,
+ char *json, char *json_end);
+ int (*json_unescape_json)(const char *json_str, const char *json_end,
+ char *res, char *res_end);
+} *json_service;
+enum json_types json_type(const char *js, const char *js_end,
+ const char **value, int *value_len);
+enum json_types json_get_array_item(const char *js, const char *js_end,
+ int n_item,
+ const char **value, int *value_len);
+enum json_types json_get_object_key(const char *js, const char *js_end,
+ const char *key,
+ const char **value, int *value_len);
+enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey,
+ const char **keyname, const char **keyname_end,
+ const char **value, int *value_len);
+int json_escape_string(const char *str,const char *str_end,
+ char *json, char *json_end);
+int json_unescape_json(const char *json_str, const char *json_end,
+ char *res, char *res_end);
+}
+}
+struct st_mysql_xid {
+ long formatID;
+ long gtrid_length;
+ long bqual_length;
+ char data[128];
+};
+typedef struct st_mysql_xid MYSQL_XID;
+enum enum_mysql_show_type
+{
+ SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
+ SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
+ SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
+ SHOW_SIZE_T, SHOW_always_last
+};
+enum enum_var_type
+{
+ SHOW_OPT_DEFAULT= 0, SHOW_OPT_SESSION, SHOW_OPT_GLOBAL
+};
+struct st_mysql_show_var {
+ const char *name;
+ void *value;
+ enum enum_mysql_show_type type;
+};
+struct system_status_var;
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+struct st_mysql_sys_var;
+struct st_mysql_value;
+typedef int (*mysql_var_check_func)(THD* thd,
+ struct st_mysql_sys_var *var,
+ void *save, struct st_mysql_value *value);
+typedef void (*mysql_var_update_func)(THD* thd,
+ struct st_mysql_sys_var *var,
+ void *var_ptr, const void *save);
+struct st_mysql_plugin
+{
+ int type;
+ void *info;
+ const char *name;
+ const char *author;
+ const char *descr;
+ int license;
+ int (*init)(void *);
+ int (*deinit)(void *);
+ unsigned int version;
+ struct st_mysql_show_var *status_vars;
+ struct st_mysql_sys_var **system_vars;
+ void * __reserved1;
+ unsigned long flags;
+};
+struct st_maria_plugin
+{
+ int type;
+ void *info;
+ const char *name;
+ const char *author;
+ const char *descr;
+ int license;
+ int (*init)(void *);
+ int (*deinit)(void *);
+ unsigned int version;
+ struct st_mysql_show_var *status_vars;
+ struct st_mysql_sys_var **system_vars;
+ const char *version_info;
+ unsigned int maturity;
+};
+extern "C" {
+enum enum_ftparser_mode
+{
+ MYSQL_FTPARSER_SIMPLE_MODE= 0,
+ MYSQL_FTPARSER_WITH_STOPWORDS= 1,
+ MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
+};
+enum enum_ft_token_type
+{
+ FT_TOKEN_EOF= 0,
+ FT_TOKEN_WORD= 1,
+ FT_TOKEN_LEFT_PAREN= 2,
+ FT_TOKEN_RIGHT_PAREN= 3,
+ FT_TOKEN_STOPWORD= 4
+};
+typedef struct st_mysql_ftparser_boolean_info
+{
+ enum enum_ft_token_type type;
+ int yesno;
+ int weight_adjust;
+ char wasign;
+ char trunc;
+ char prev;
+ char *quot;
+} MYSQL_FTPARSER_BOOLEAN_INFO;
+typedef struct st_mysql_ftparser_param
+{
+ int (*mysql_parse)(struct st_mysql_ftparser_param *,
+ const char *doc, int doc_len);
+ int (*mysql_add_word)(struct st_mysql_ftparser_param *,
+ const char *word, int word_len,
+ MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
+ void *ftparser_state;
+ void *mysql_ftparam;
+ const struct charset_info_st *cs;
+ const char *doc;
+ int length;
+ unsigned int flags;
+ enum enum_ftparser_mode mode;
+} MYSQL_FTPARSER_PARAM;
+struct st_mysql_ftparser
+{
+ int interface_version;
+ int (*parse)(MYSQL_FTPARSER_PARAM *param);
+ int (*init)(MYSQL_FTPARSER_PARAM *param);
+ int (*deinit)(MYSQL_FTPARSER_PARAM *param);
+};
+}
+struct st_mysql_daemon
+{
+ int interface_version;
+};
+struct st_mysql_information_schema
+{
+ int interface_version;
+};
+struct st_mysql_storage_engine
+{
+ int interface_version;
+};
+struct handlerton;
+ struct Mysql_replication {
+ int interface_version;
+ };
+struct st_mysql_value
+{
+ int (*value_type)(struct st_mysql_value *);
+ const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
+ int (*val_real)(struct st_mysql_value *, double *realbuf);
+ int (*val_int)(struct st_mysql_value *, long long *intbuf);
+ int (*is_unsigned)(struct st_mysql_value *);
+};
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
+int mysql_tmpfile(const char *prefix);
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
+ const char *key, unsigned int key_length,
+ int using_trx);
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
+ const void *ha_data);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+struct st_mariadb_data_type
+{
+ int interface_version;
+ const class Type_handler *type_handler;
+};
diff --git a/plugin/type_test/CMakeLists.txt b/plugin/type_test/CMakeLists.txt
new file mode 100644
index 00000000000..b85168d1bd2
--- /dev/null
+++ b/plugin/type_test/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright (c) 2016, MariaDB corporation. All rights reserved.
+#
+# 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 Street, Fifth Floor, Boston, MA 02110-1335 USA
+
+MYSQL_ADD_PLUGIN(type_test plugin.cc RECOMPILE_FOR_EMBEDDED
+ MODULE_ONLY COMPONENT Test)
diff --git a/plugin/type_test/mysql-test/type_test/suite.opt b/plugin/type_test/mysql-test/type_test/suite.opt
new file mode 100644
index 00000000000..edf6d838a78
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/suite.opt
@@ -0,0 +1 @@
+--plugin-load-add=$TYPE_TEST_SO
diff --git a/plugin/type_test/mysql-test/type_test/suite.pm b/plugin/type_test/mysql-test/type_test/suite.pm
new file mode 100644
index 00000000000..fe38ca57650
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/suite.pm
@@ -0,0 +1,10 @@
+package My::Suite::Type_test;
+
+@ISA = qw(My::Suite);
+
+return "No TYPE_TEST plugin" unless $ENV{TYPE_TEST_SO};
+
+sub is_default { 1 }
+
+bless { };
+
diff --git a/plugin/type_test/mysql-test/type_test/type_test_double-debug.result b/plugin/type_test/mysql-test/type_test/type_test_double-debug.result
new file mode 100644
index 00000000000..975decca11e
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_double-debug.result
@@ -0,0 +1,35 @@
+#
+# MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+#
+# Testing that a user-defined handler is resolved by name
+# when opening a FRM file.
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_DOUBLE);
+Warnings:
+Note 1105 build_frm_image: Field data type info length: 13
+Note 1105 DBUG: [0] name='a' type_info='test_double'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Warnings:
+Note 1105 DBUG: [0] name='a' type_info='test_double'
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
+# Testing what happens on failure to resolve a type handler by name
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_DOUBLE);
+Warnings:
+Note 1105 build_frm_image: Field data type info length: 13
+Note 1105 DBUG: [0] name='a' type_info='test_double'
+FLUSH TABLES;
+SET @@debug_dbug="+d,emulate_handler_by_name_or_error_failure";
+SHOW CREATE TABLE t1;
+ERROR HY000: Unknown data type: 'test_double'
+SELECT * FROM t1;
+ERROR HY000: Unknown data type: 'test_double'
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_double-debug.test b/plugin/type_test/mysql-test/type_test/type_test_double-debug.test
new file mode 100644
index 00000000000..139a7a09ddd
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_double-debug.test
@@ -0,0 +1,30 @@
+--source include/have_debug.inc
+
+--echo #
+--echo # MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+--echo #
+
+--echo # Testing that a user-defined handler is resolved by name
+--echo # when opening a FRM file.
+
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_DOUBLE);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
+
+
+--echo # Testing what happens on failure to resolve a type handler by name
+
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_DOUBLE);
+FLUSH TABLES;
+SET @@debug_dbug="+d,emulate_handler_by_name_or_error_failure";
+--error ER_UNKNOWN_DATA_TYPE
+SHOW CREATE TABLE t1;
+--error ER_UNKNOWN_DATA_TYPE
+SELECT * FROM t1;
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_double.result b/plugin/type_test/mysql-test/type_test/type_test_double.result
new file mode 100644
index 00000000000..f07f892e298
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_double.result
@@ -0,0 +1,691 @@
+#
+# MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+#
+SELECT
+PLUGIN_NAME,
+PLUGIN_VERSION,
+PLUGIN_STATUS,
+PLUGIN_TYPE,
+PLUGIN_AUTHOR,
+PLUGIN_DESCRIPTION,
+PLUGIN_LICENSE,
+PLUGIN_MATURITY,
+PLUGIN_AUTH_VERSION
+FROM INFORMATION_SCHEMA.PLUGINS
+WHERE PLUGIN_TYPE='DATA TYPE'
+ AND PLUGIN_NAME='test_double';
+PLUGIN_NAME test_double
+PLUGIN_VERSION 1.0
+PLUGIN_STATUS ACTIVE
+PLUGIN_TYPE DATA TYPE
+PLUGIN_AUTHOR MariaDB Corporation
+PLUGIN_DESCRIPTION Data type TEST_DOUBLE
+PLUGIN_LICENSE GPL
+PLUGIN_MATURITY Experimental
+PLUGIN_AUTH_VERSION 1.0
+CREATE TABLE t1 (a TEST_DOUBLE);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE(4));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double(4,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE(10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double(10,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE(20));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double(20,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE(4,2));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double(4,2) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE(10,5));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double(10,5) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE(20,10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double(20,10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT CAST('100' AS TEST_DOUBLE) AS cast;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def cast 5 22 3 Y 32896 31 63
+cast
+100
+BEGIN NOT ATOMIC
+DECLARE a TEST_DOUBLE DEFAULT 256;
+SELECT HEX(a), a;
+END;
+$$
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def HEX(a) 253 44 3 Y 0 0 8
+def a a 5 22 3 Y 32768 31 63
+HEX(a) a
+100 256
+CREATE FUNCTION f1(p TEST_DOUBLE) RETURNS TEST_DOUBLE RETURN 1;
+SHOW CREATE FUNCTION f1;
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(p TEST_DOUBLE) RETURNS test_double
+RETURN 1 latin1 latin1_swedish_ci latin1_swedish_ci
+SELECT f1(10);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def f1(10) f1(10) 5 22 1 Y 32768 31 63
+f1(10)
+1
+DROP FUNCTION f1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT COALESCE(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `COALESCE(a,a)` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `LEAST(a,a)` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT MIN(a), MAX(a) FROM t1;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 MIN(a) MIN(a) 5 22 1 Y 32768 31 63
+def test t2 t2 MAX(a) MAX(a) 5 22 1 Y 32768 31 63
+MIN(a) MAX(a)
+1 2
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `MIN(a)` test_double DEFAULT NULL,
+ `MAX(a)` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,1),(2,2);
+CREATE TABLE t2 AS SELECT id, MIN(a), MAX(a) FROM t1 GROUP BY id;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 id id 3 11 1 Y 32768 0 63
+def test t2 t2 MIN(a) MIN(a) 5 22 1 Y 32768 31 63
+def test t2 t2 MAX(a) MAX(a) 5 22 1 Y 32768 31 63
+id MIN(a) MAX(a)
+1 1 2
+2 1 2
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) DEFAULT NULL,
+ `MIN(a)` test_double DEFAULT NULL,
+ `MAX(a)` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT DISTINCT a FROM t1;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 a a 5 22 1 Y 32768 31 63
+a
+1
+2
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT (SELECT a FROM t1) AS c1;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 c1 c1 5 22 1 Y 32768 31 63
+c1
+1
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+# Testing CREATE..LIKE
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+# Testing CREATE..SELECT
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT * FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+# Testing ALTER
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (10),(20);
+SELECT * FROM t1;
+a
+10
+20
+ALTER TABLE t1 MODIFY a INT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a
+10
+20
+ALTER TABLE t1 MODIFY a TEST_DOUBLE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a
+10
+20
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (10),(20);
+ALTER TABLE t1 ADD b TEST_DOUBLE DEFAULT 0;
+SELECT * FROM t1;
+a b
+10 0
+20 0
+DROP TABLE t1;
+# Testing metadata views
+CREATE TABLE t1 (a TEST_DOUBLE);
+SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME t1
+COLUMN_NAME a
+ORDINAL_POSITION 1
+COLUMN_DEFAULT NULL
+IS_NULLABLE YES
+DATA_TYPE test_double
+CHARACTER_MAXIMUM_LENGTH NULL
+CHARACTER_OCTET_LENGTH NULL
+NUMERIC_PRECISION 22
+NUMERIC_SCALE 31
+DATETIME_PRECISION NULL
+CHARACTER_SET_NAME NULL
+COLLATION_NAME NULL
+COLUMN_TYPE test_double
+COLUMN_KEY
+EXTRA
+PRIVILEGES select,insert,update,references
+COLUMN_COMMENT
+IS_GENERATED NEVER
+GENERATION_EXPRESSION NULL
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+a test_double YES NULL
+DROP TABLE t1;
+# Testing indexing
+CREATE TABLE t1 (a TEST_DOUBLE, KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+EXPLAIN SELECT * FROM t1 WHERE a=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 9 const 1 Using index
+DROP TABLE t1;
+# Testing aggregation for result
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+COALESCE(a,1) AS c1,
+COALESCE(a,1.0) AS c2,
+COALESCE(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_double DEFAULT NULL,
+ `c2` test_double DEFAULT NULL,
+ `c3` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+0 0 0
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+COALESCE(c,c_tinyint),
+COALESCE(c,c_smallint),
+COALESCE(c,c_mediumint),
+COALESCE(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `COALESCE(c,c_tinyint)` test_double DEFAULT NULL,
+ `COALESCE(c,c_smallint)` test_double DEFAULT NULL,
+ `COALESCE(c,c_mediumint)` test_double DEFAULT NULL,
+ `COALESCE(c,c_bigint)` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT COALESCE(c, c_time) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and time for operation 'coalesce'
+SELECT COALESCE(c, c_date) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and date for operation 'coalesce'
+SELECT COALESCE(c, c_datetime) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and datetime for operation 'coalesce'
+SELECT COALESCE(c, c_timestamp) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and timestamp for operation 'coalesce'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT COALESCE(c, c_char) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and char for operation 'coalesce'
+SELECT COALESCE(c, c_varchar) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and varchar for operation 'coalesce'
+SELECT COALESCE(c, c_tinytext) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and tinyblob for operation 'coalesce'
+SELECT COALESCE(c, c_text) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and blob for operation 'coalesce'
+SELECT COALESCE(c, c_mediumtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and mediumblob for operation 'coalesce'
+SELECT COALESCE(c, c_longtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and longblob for operation 'coalesce'
+DROP TABLE t1;
+# Testing aggregation for min/max
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+LEAST(a,1) AS c1,
+LEAST(a,1.0) AS c2,
+LEAST(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_double DEFAULT NULL,
+ `c2` test_double DEFAULT NULL,
+ `c3` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+0 0 0
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+LEAST(c,c_tinyint),
+LEAST(c,c_smallint),
+LEAST(c,c_mediumint),
+LEAST(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `LEAST(c,c_tinyint)` test_double DEFAULT NULL,
+ `LEAST(c,c_smallint)` test_double DEFAULT NULL,
+ `LEAST(c,c_mediumint)` test_double DEFAULT NULL,
+ `LEAST(c,c_bigint)` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT LEAST(c, c_time) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and time for operation 'least'
+SELECT LEAST(c, c_date) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and date for operation 'least'
+SELECT LEAST(c, c_datetime) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and datetime for operation 'least'
+SELECT LEAST(c, c_timestamp) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and timestamp for operation 'least'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT LEAST(c, c_char) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and char for operation 'least'
+SELECT LEAST(c, c_varchar) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and varchar for operation 'least'
+SELECT LEAST(c, c_tinytext) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and tinyblob for operation 'least'
+SELECT LEAST(c, c_text) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and blob for operation 'least'
+SELECT LEAST(c, c_mediumtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and mediumblob for operation 'least'
+SELECT LEAST(c, c_longtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_double and longblob for operation 'least'
+DROP TABLE t1;
+# Testing aggregation for numeric operation - plus
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+a+1 AS c1,
+a+1.0 AS c2,
+a+1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_double DEFAULT NULL,
+ `c2` test_double DEFAULT NULL,
+ `c3` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+c + c_tinyint,
+c + c_smallint,
+c + c_mediumint,
+c + c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c + c_tinyint` test_double DEFAULT NULL,
+ `c + c_smallint` test_double DEFAULT NULL,
+ `c + c_mediumint` test_double DEFAULT NULL,
+ `c + c_bigint` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT c + c_time FROM t1;
+ERROR HY000: Illegal parameter data types test_double and time for operation '+'
+SELECT c + c_date FROM t1;
+ERROR HY000: Illegal parameter data types test_double and date for operation '+'
+SELECT c + c_datetime FROM t1;
+ERROR HY000: Illegal parameter data types test_double and datetime for operation '+'
+SELECT c + c_timestamp FROM t1;
+ERROR HY000: Illegal parameter data types test_double and timestamp for operation '+'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT c + c_char FROM t1;
+ERROR HY000: Illegal parameter data types test_double and char for operation '+'
+SELECT c + c_varchar FROM t1;
+ERROR HY000: Illegal parameter data types test_double and varchar for operation '+'
+SELECT c + c_tinytext FROM t1;
+ERROR HY000: Illegal parameter data types test_double and tinyblob for operation '+'
+SELECT c + c_text FROM t1;
+ERROR HY000: Illegal parameter data types test_double and blob for operation '+'
+SELECT c + c_mediumtext FROM t1;
+ERROR HY000: Illegal parameter data types test_double and mediumblob for operation '+'
+SELECT c + c_longtext FROM t1;
+ERROR HY000: Illegal parameter data types test_double and longblob for operation '+'
+DROP TABLE t1;
+# Testing aggregation for numeric operation - minus
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+CREATE TABLE t2 AS SELECT
+a-1 AS c1,
+a-1.0 AS c2,
+a-1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_double DEFAULT NULL,
+ `c2` test_double DEFAULT NULL,
+ `c3` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+0 0 0
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+c - c_tinyint,
+c - c_smallint,
+c - c_mediumint,
+c - c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c - c_tinyint` test_double DEFAULT NULL,
+ `c - c_smallint` test_double DEFAULT NULL,
+ `c - c_mediumint` test_double DEFAULT NULL,
+ `c - c_bigint` test_double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT c - c_time FROM t1;
+ERROR HY000: Illegal parameter data types test_double and time for operation '-'
+SELECT c - c_date FROM t1;
+ERROR HY000: Illegal parameter data types test_double and date for operation '-'
+SELECT c - c_datetime FROM t1;
+ERROR HY000: Illegal parameter data types test_double and datetime for operation '-'
+SELECT c - c_timestamp FROM t1;
+ERROR HY000: Illegal parameter data types test_double and timestamp for operation '-'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_DOUBLE,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT c - c_char FROM t1;
+ERROR HY000: Illegal parameter data types test_double and char for operation '-'
+SELECT c - c_varchar FROM t1;
+ERROR HY000: Illegal parameter data types test_double and varchar for operation '-'
+SELECT c - c_tinytext FROM t1;
+ERROR HY000: Illegal parameter data types test_double and tinyblob for operation '-'
+SELECT c - c_text FROM t1;
+ERROR HY000: Illegal parameter data types test_double and blob for operation '-'
+SELECT c - c_mediumtext FROM t1;
+ERROR HY000: Illegal parameter data types test_double and mediumblob for operation '-'
+SELECT c - c_longtext FROM t1;
+ERROR HY000: Illegal parameter data types test_double and longblob for operation '-'
+DROP TABLE t1;
+# Testing CAST to other data types
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (20000102);
+CREATE TABLE t2 AS SELECT
+a,
+CAST(a AS CHAR),
+CAST(a AS DECIMAL),
+CAST(a AS DOUBLE),
+CAST(a AS SIGNED),
+CAST(a AS UNSIGNED),
+CAST(a AS TIME),
+CAST(a AS DATETIME),
+CAST(a AS DATE)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_double DEFAULT NULL,
+ `CAST(a AS CHAR)` varchar(22) DEFAULT NULL,
+ `CAST(a AS DECIMAL)` decimal(10,0) DEFAULT NULL,
+ `CAST(a AS DOUBLE)` double DEFAULT NULL,
+ `CAST(a AS SIGNED)` bigint(20) DEFAULT NULL,
+ `CAST(a AS UNSIGNED)` bigint(20) unsigned DEFAULT NULL,
+ `CAST(a AS TIME)` time DEFAULT NULL,
+ `CAST(a AS DATETIME)` datetime DEFAULT NULL,
+ `CAST(a AS DATE)` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2;
+a 20000102
+CAST(a AS CHAR) 20000102
+CAST(a AS DECIMAL) 20000102
+CAST(a AS DOUBLE) 20000102
+CAST(a AS SIGNED) 20000102
+CAST(a AS UNSIGNED) 20000102
+CAST(a AS TIME) 00:00:00
+CAST(a AS DATETIME) 2000-01-02 00:00:00
+CAST(a AS DATE) 2000-01-02
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_double.test b/plugin/type_test/mysql-test/type_test/type_test_double.test
new file mode 100644
index 00000000000..06f468cefe9
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_double.test
@@ -0,0 +1,512 @@
+--echo #
+--echo # MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+--echo #
+
+--vertical_results
+SELECT
+ PLUGIN_NAME,
+ PLUGIN_VERSION,
+ PLUGIN_STATUS,
+ PLUGIN_TYPE,
+ PLUGIN_AUTHOR,
+ PLUGIN_DESCRIPTION,
+ PLUGIN_LICENSE,
+ PLUGIN_MATURITY,
+ PLUGIN_AUTH_VERSION
+FROM INFORMATION_SCHEMA.PLUGINS
+ WHERE PLUGIN_TYPE='DATA TYPE'
+ AND PLUGIN_NAME='test_double';
+--horizontal_results
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE(4));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE(10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE(20));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (a TEST_DOUBLE(4,2));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE(10,5));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE(20,10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--disable_ps_protocol
+--enable_metadata
+SELECT CAST('100' AS TEST_DOUBLE) AS cast;
+--disable_metadata
+--enable_ps_protocol
+
+--disable_ps_protocol
+--enable_metadata
+DELIMITER $$;
+BEGIN NOT ATOMIC
+ DECLARE a TEST_DOUBLE DEFAULT 256;
+ SELECT HEX(a), a;
+END;
+$$
+DELIMITER ;$$
+--disable_metadata
+--enable_ps_protocol
+
+CREATE FUNCTION f1(p TEST_DOUBLE) RETURNS TEST_DOUBLE RETURN 1;
+SHOW CREATE FUNCTION f1;
+--disable_ps_protocol
+--enable_metadata
+SELECT f1(10);
+--disable_metadata
+--enable_ps_protocol
+DROP FUNCTION f1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT COALESCE(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT MIN(a), MAX(a) FROM t1;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (id INT, a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,1),(2,2);
+CREATE TABLE t2 AS SELECT id, MIN(a), MAX(a) FROM t1 GROUP BY id;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT DISTINCT a FROM t1;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT (SELECT a FROM t1) AS c1;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo # Testing CREATE..LIKE
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo # Testing CREATE..SELECT
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+CREATE TABLE t2 AS SELECT * FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+
+--echo # Testing ALTER
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (10),(20);
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY a INT;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY a TEST_DOUBLE;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (10),(20);
+ALTER TABLE t1 ADD b TEST_DOUBLE DEFAULT 0;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo # Testing metadata views
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+--vertical_results
+SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+--horizontal_results
+SHOW COLUMNS FROM t1;
+DROP TABLE t1;
+
+
+--echo # Testing indexing
+
+CREATE TABLE t1 (a TEST_DOUBLE, KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+EXPLAIN SELECT * FROM t1 WHERE a=3;
+DROP TABLE t1;
+
+--echo # Testing aggregation for result
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+ COALESCE(a,1) AS c1,
+ COALESCE(a,1.0) AS c2,
+ COALESCE(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ COALESCE(c,c_tinyint),
+ COALESCE(c,c_smallint),
+ COALESCE(c,c_mediumint),
+ COALESCE(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_time) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_date) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_datetime) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_timestamp) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_char) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_varchar) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_tinytext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_text) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_mediumtext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_longtext) FROM t1;
+DROP TABLE t1;
+
+--echo # Testing aggregation for min/max
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+ LEAST(a,1) AS c1,
+ LEAST(a,1.0) AS c2,
+ LEAST(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ LEAST(c,c_tinyint),
+ LEAST(c,c_smallint),
+ LEAST(c,c_mediumint),
+ LEAST(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_time) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_date) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_datetime) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_timestamp) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_char) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_varchar) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_tinytext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_text) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_mediumtext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_longtext) FROM t1;
+DROP TABLE t1;
+
+
+--echo # Testing aggregation for numeric operation - plus
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+ a+1 AS c1,
+ a+1.0 AS c2,
+ a+1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ c + c_tinyint,
+ c + c_smallint,
+ c + c_mediumint,
+ c + c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_time FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_date FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_datetime FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_timestamp FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_char FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_varchar FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_tinytext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_text FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_mediumtext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_longtext FROM t1;
+DROP TABLE t1;
+
+--echo # Testing aggregation for numeric operation - minus
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+CREATE TABLE t2 AS SELECT
+ a-1 AS c1,
+ a-1.0 AS c2,
+ a-1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ c - c_tinyint,
+ c - c_smallint,
+ c - c_mediumint,
+ c - c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_time FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_date FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_datetime FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_timestamp FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_DOUBLE,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_char FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_varchar FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_tinytext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_text FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_mediumtext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_longtext FROM t1;
+DROP TABLE t1;
+
+--echo # Testing CAST to other data types
+
+CREATE TABLE t1 (a TEST_DOUBLE);
+INSERT INTO t1 VALUES (20000102);
+CREATE TABLE t2 AS SELECT
+ a,
+ CAST(a AS CHAR),
+ CAST(a AS DECIMAL),
+ CAST(a AS DOUBLE),
+ CAST(a AS SIGNED),
+ CAST(a AS UNSIGNED),
+ CAST(a AS TIME),
+ CAST(a AS DATETIME),
+ CAST(a AS DATE)
+FROM t1;
+SHOW CREATE TABLE t2;
+--vertical_results
+SELECT * FROM t2;
+--horizontal_results
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_int8-debug.result b/plugin/type_test/mysql-test/type_test/type_test_int8-debug.result
new file mode 100644
index 00000000000..952a63c8476
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_int8-debug.result
@@ -0,0 +1,35 @@
+#
+# MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+#
+# Testing that a user-defined handler is resolved by name
+# when opening a FRM file.
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_INT8);
+Warnings:
+Note 1105 build_frm_image: Field data type info length: 11
+Note 1105 DBUG: [0] name='a' type_info='test_int8'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Warnings:
+Note 1105 DBUG: [0] name='a' type_info='test_int8'
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
+# Testing what happens on failure to resolve a type handler by name
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_INT8);
+Warnings:
+Note 1105 build_frm_image: Field data type info length: 11
+Note 1105 DBUG: [0] name='a' type_info='test_int8'
+FLUSH TABLES;
+SET @@debug_dbug="+d,emulate_handler_by_name_or_error_failure";
+SHOW CREATE TABLE t1;
+ERROR HY000: Unknown data type: 'test_int8'
+SELECT * FROM t1;
+ERROR HY000: Unknown data type: 'test_int8'
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_int8-debug.test b/plugin/type_test/mysql-test/type_test/type_test_int8-debug.test
new file mode 100644
index 00000000000..d79575f3c78
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_int8-debug.test
@@ -0,0 +1,30 @@
+--source include/have_debug.inc
+
+--echo #
+--echo # MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+--echo #
+
+--echo # Testing that a user-defined handler is resolved by name
+--echo # when opening a FRM file.
+
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_INT8);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
+
+
+--echo # Testing what happens on failure to resolve a type handler by name
+
+SET @old_debug_dbug=@@debug_dbug;
+SET @@debug_dbug="+d,frm_data_type_info";
+CREATE TABLE t1 (a TEST_INT8);
+FLUSH TABLES;
+SET @@debug_dbug="+d,emulate_handler_by_name_or_error_failure";
+--error ER_UNKNOWN_DATA_TYPE
+SHOW CREATE TABLE t1;
+--error ER_UNKNOWN_DATA_TYPE
+SELECT * FROM t1;
+DROP TABLE t1;
+SET @@debug_dbug=@old_debug_dbug;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_int8.result b/plugin/type_test/mysql-test/type_test/type_test_int8.result
new file mode 100644
index 00000000000..e5bd69a27c3
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_int8.result
@@ -0,0 +1,670 @@
+#
+# MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+#
+SELECT
+PLUGIN_NAME,
+PLUGIN_VERSION,
+PLUGIN_STATUS,
+PLUGIN_TYPE,
+PLUGIN_AUTHOR,
+PLUGIN_DESCRIPTION,
+PLUGIN_LICENSE,
+PLUGIN_MATURITY,
+PLUGIN_AUTH_VERSION
+FROM INFORMATION_SCHEMA.PLUGINS
+WHERE PLUGIN_TYPE='DATA TYPE'
+ AND PLUGIN_NAME='test_int8';
+PLUGIN_NAME test_int8
+PLUGIN_VERSION 1.0
+PLUGIN_STATUS ACTIVE
+PLUGIN_TYPE DATA TYPE
+PLUGIN_AUTHOR MariaDB Corporation
+PLUGIN_DESCRIPTION Data type TEST_INT8
+PLUGIN_LICENSE GPL
+PLUGIN_MATURITY Experimental
+PLUGIN_AUTH_VERSION 1.0
+CREATE TABLE t1 (a TEST_INT8);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8(4));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_int8(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8(10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_int8(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8(20));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT CAST('100' AS TEST_INT8) AS cast;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def cast 3 3 3 N 32897 0 63
+cast
+100
+BEGIN NOT ATOMIC
+DECLARE a TEST_INT8 DEFAULT 256;
+SELECT HEX(a), a;
+END;
+$$
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def HEX(a) 253 40 3 Y 0 0 8
+def a a 8 20 3 Y 32768 0 63
+HEX(a) a
+100 256
+CREATE FUNCTION f1(p TEST_INT8) RETURNS TEST_INT8 RETURN 1;
+SHOW CREATE FUNCTION f1;
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(p TEST_INT8) RETURNS test_int8(20)
+RETURN 1 latin1 latin1_swedish_ci latin1_swedish_ci
+SELECT f1(10);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def f1(10) f1(10) 8 20 1 Y 32768 0 63
+f1(10)
+1
+DROP FUNCTION f1;
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT COALESCE(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `COALESCE(a,a)` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `LEAST(a,a)` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT MIN(a), MAX(a) FROM t1;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 MIN(a) MIN(a) 8 20 1 Y 32768 0 63
+def test t2 t2 MAX(a) MAX(a) 8 20 1 Y 32768 0 63
+MIN(a) MAX(a)
+1 2
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `MIN(a)` test_int8(20) DEFAULT NULL,
+ `MAX(a)` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, a TEST_INT8);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,1),(2,2);
+CREATE TABLE t2 AS SELECT id, MIN(a), MAX(a) FROM t1 GROUP BY id;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 id id 3 11 1 Y 32768 0 63
+def test t2 t2 MIN(a) MIN(a) 8 20 1 Y 32768 0 63
+def test t2 t2 MAX(a) MAX(a) 8 20 1 Y 32768 0 63
+id MIN(a) MAX(a)
+1 1 2
+2 1 2
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) DEFAULT NULL,
+ `MIN(a)` test_int8(20) DEFAULT NULL,
+ `MAX(a)` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT DISTINCT a FROM t1;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 a a 8 20 1 Y 32768 0 63
+a
+1
+2
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT (SELECT a FROM t1) AS c1;
+SELECT * FROM t2;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t2 t2 c1 c1 8 20 1 Y 32768 0 63
+c1
+1
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+# Testing CREATE..LIKE
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+# Testing CREATE..SELECT
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT * FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+# Testing ALTER
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (10),(20);
+SELECT * FROM t1;
+a
+10
+20
+ALTER TABLE t1 MODIFY a INT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a
+10
+20
+ALTER TABLE t1 MODIFY a TEST_INT8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a
+10
+20
+DROP TABLE t1;
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (10),(20);
+ALTER TABLE t1 ADD b TEST_INT8 DEFAULT 0;
+SELECT * FROM t1;
+a b
+10 0
+20 0
+DROP TABLE t1;
+# Testing metadata views
+CREATE TABLE t1 (a TEST_INT8);
+SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME t1
+COLUMN_NAME a
+ORDINAL_POSITION 1
+COLUMN_DEFAULT NULL
+IS_NULLABLE YES
+DATA_TYPE test_int8
+CHARACTER_MAXIMUM_LENGTH NULL
+CHARACTER_OCTET_LENGTH NULL
+NUMERIC_PRECISION 19
+NUMERIC_SCALE 0
+DATETIME_PRECISION NULL
+CHARACTER_SET_NAME NULL
+COLLATION_NAME NULL
+COLUMN_TYPE test_int8(20)
+COLUMN_KEY
+EXTRA
+PRIVILEGES select,insert,update,references
+COLUMN_COMMENT
+IS_GENERATED NEVER
+GENERATION_EXPRESSION NULL
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+a test_int8(20) YES NULL
+DROP TABLE t1;
+# Testing indexing
+CREATE TABLE t1 (a TEST_INT8, KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+EXPLAIN SELECT * FROM t1 WHERE a=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 9 const 1 Using index
+DROP TABLE t1;
+# Testing aggregation for result
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+COALESCE(a,1) AS c1,
+COALESCE(a,1.0) AS c2,
+COALESCE(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_int8(20) DEFAULT NULL,
+ `c2` decimal(20,1) DEFAULT NULL,
+ `c3` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+0 0.0 0
+1 1.0 1
+2 2.0 2
+3 3.0 3
+4 4.0 4
+5 5.0 5
+6 6.0 6
+7 7.0 7
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+COALESCE(c,c_tinyint),
+COALESCE(c,c_smallint),
+COALESCE(c,c_mediumint),
+COALESCE(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `COALESCE(c,c_tinyint)` test_int8(20) DEFAULT NULL,
+ `COALESCE(c,c_smallint)` test_int8(20) DEFAULT NULL,
+ `COALESCE(c,c_mediumint)` test_int8(20) DEFAULT NULL,
+ `COALESCE(c,c_bigint)` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT COALESCE(c, c_time) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and time for operation 'coalesce'
+SELECT COALESCE(c, c_date) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and date for operation 'coalesce'
+SELECT COALESCE(c, c_datetime) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and datetime for operation 'coalesce'
+SELECT COALESCE(c, c_timestamp) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and timestamp for operation 'coalesce'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT COALESCE(c, c_char) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and char for operation 'coalesce'
+SELECT COALESCE(c, c_varchar) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and varchar for operation 'coalesce'
+SELECT COALESCE(c, c_tinytext) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and tinyblob for operation 'coalesce'
+SELECT COALESCE(c, c_text) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and blob for operation 'coalesce'
+SELECT COALESCE(c, c_mediumtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and mediumblob for operation 'coalesce'
+SELECT COALESCE(c, c_longtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and longblob for operation 'coalesce'
+DROP TABLE t1;
+# Testing aggregation for min/max
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+LEAST(a,1) AS c1,
+LEAST(a,1.0) AS c2,
+LEAST(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` test_int8(20) DEFAULT NULL,
+ `c2` decimal(20,1) DEFAULT NULL,
+ `c3` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+0 0.0 0
+1 1.0 1
+1 1.0 1
+1 1.0 1
+1 1.0 1
+1 1.0 1
+1 1.0 1
+1 1.0 1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+LEAST(c,c_tinyint),
+LEAST(c,c_smallint),
+LEAST(c,c_mediumint),
+LEAST(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `LEAST(c,c_tinyint)` test_int8(20) DEFAULT NULL,
+ `LEAST(c,c_smallint)` test_int8(20) DEFAULT NULL,
+ `LEAST(c,c_mediumint)` test_int8(20) DEFAULT NULL,
+ `LEAST(c,c_bigint)` test_int8(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT LEAST(c, c_time) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and time for operation 'least'
+SELECT LEAST(c, c_date) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and date for operation 'least'
+SELECT LEAST(c, c_datetime) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and datetime for operation 'least'
+SELECT LEAST(c, c_timestamp) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and timestamp for operation 'least'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT LEAST(c, c_char) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and char for operation 'least'
+SELECT LEAST(c, c_varchar) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and varchar for operation 'least'
+SELECT LEAST(c, c_tinytext) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and tinyblob for operation 'least'
+SELECT LEAST(c, c_text) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and blob for operation 'least'
+SELECT LEAST(c, c_mediumtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and mediumblob for operation 'least'
+SELECT LEAST(c, c_longtext) FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and longblob for operation 'least'
+DROP TABLE t1;
+# Testing aggregation for numeric operation - plus
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+a+1 AS c1,
+a+1.0 AS c2,
+a+1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` bigint(21) DEFAULT NULL,
+ `c2` decimal(21,1) DEFAULT NULL,
+ `c3` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+1 1.0 1
+2 2.0 2
+3 3.0 3
+4 4.0 4
+5 5.0 5
+6 6.0 6
+7 7.0 7
+8 8.0 8
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+c + c_tinyint,
+c + c_smallint,
+c + c_mediumint,
+c + c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c + c_tinyint` bigint(21) DEFAULT NULL,
+ `c + c_smallint` bigint(21) DEFAULT NULL,
+ `c + c_mediumint` bigint(21) DEFAULT NULL,
+ `c + c_bigint` bigint(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT c + c_time FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and time for operation '+'
+SELECT c + c_date FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and date for operation '+'
+SELECT c + c_datetime FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and datetime for operation '+'
+SELECT c + c_timestamp FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and timestamp for operation '+'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT c + c_char FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and char for operation '+'
+SELECT c + c_varchar FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and varchar for operation '+'
+SELECT c + c_tinytext FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and tinyblob for operation '+'
+SELECT c + c_text FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and blob for operation '+'
+SELECT c + c_mediumtext FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and mediumblob for operation '+'
+SELECT c + c_longtext FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and longblob for operation '+'
+DROP TABLE t1;
+# Testing aggregation for numeric operation - minus
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+CREATE TABLE t2 AS SELECT
+a-1 AS c1,
+a-1.0 AS c2,
+a-1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` bigint(21) DEFAULT NULL,
+ `c2` decimal(21,1) DEFAULT NULL,
+ `c3` double DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2 ORDER BY c1;
+c1 c2 c3
+0 0.0 0
+1 1.0 1
+2 2.0 2
+3 3.0 3
+4 4.0 4
+5 5.0 5
+6 6.0 6
+7 7.0 7
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_tinyint TINYINT,
+c_smallint SMALLINT,
+c_mediumint MEDIUMINT,
+c_int INT,
+c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+c - c_tinyint,
+c - c_smallint,
+c - c_mediumint,
+c - c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c - c_tinyint` bigint(21) DEFAULT NULL,
+ `c - c_smallint` bigint(21) DEFAULT NULL,
+ `c - c_mediumint` bigint(21) DEFAULT NULL,
+ `c - c_bigint` bigint(21) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_time TIME,
+c_date DATE,
+c_datetime DATETIME,
+c_timestamp TIMESTAMP
+);
+SELECT c - c_time FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and time for operation '-'
+SELECT c - c_date FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and date for operation '-'
+SELECT c - c_datetime FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and datetime for operation '-'
+SELECT c - c_timestamp FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and timestamp for operation '-'
+DROP TABLE t1;
+CREATE TABLE t1 (
+c TEST_INT8,
+c_char CHAR(32),
+c_varchar VARCHAR(32),
+c_tinytext TINYTEXT,
+c_text TEXT,
+c_mediumtext MEDIUMTEXT,
+c_longtext LONGTEXT
+);
+SELECT c - c_char FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and char for operation '-'
+SELECT c - c_varchar FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and varchar for operation '-'
+SELECT c - c_tinytext FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and tinyblob for operation '-'
+SELECT c - c_text FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and blob for operation '-'
+SELECT c - c_mediumtext FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and mediumblob for operation '-'
+SELECT c - c_longtext FROM t1;
+ERROR HY000: Illegal parameter data types test_int8 and longblob for operation '-'
+DROP TABLE t1;
+# Testing CAST to other data types
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (20000102);
+CREATE TABLE t2 AS SELECT
+a,
+CAST(a AS CHAR),
+CAST(a AS DECIMAL),
+CAST(a AS DOUBLE),
+CAST(a AS SIGNED),
+CAST(a AS UNSIGNED),
+CAST(a AS TIME),
+CAST(a AS DATETIME),
+CAST(a AS DATE)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` test_int8(20) DEFAULT NULL,
+ `CAST(a AS CHAR)` varchar(20) DEFAULT NULL,
+ `CAST(a AS DECIMAL)` decimal(10,0) DEFAULT NULL,
+ `CAST(a AS DOUBLE)` double DEFAULT NULL,
+ `CAST(a AS SIGNED)` bigint(20) DEFAULT NULL,
+ `CAST(a AS UNSIGNED)` bigint(20) unsigned DEFAULT NULL,
+ `CAST(a AS TIME)` time DEFAULT NULL,
+ `CAST(a AS DATETIME)` datetime DEFAULT NULL,
+ `CAST(a AS DATE)` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2;
+a 20000102
+CAST(a AS CHAR) 20000102
+CAST(a AS DECIMAL) 20000102
+CAST(a AS DOUBLE) 20000102
+CAST(a AS SIGNED) 20000102
+CAST(a AS UNSIGNED) 20000102
+CAST(a AS TIME) 00:00:00
+CAST(a AS DATETIME) 2000-01-02 00:00:00
+CAST(a AS DATE) 2000-01-02
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_int8.test b/plugin/type_test/mysql-test/type_test/type_test_int8.test
new file mode 100644
index 00000000000..3ba0f96d1db
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_int8.test
@@ -0,0 +1,500 @@
+--echo #
+--echo # MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
+--echo #
+
+--vertical_results
+SELECT
+ PLUGIN_NAME,
+ PLUGIN_VERSION,
+ PLUGIN_STATUS,
+ PLUGIN_TYPE,
+ PLUGIN_AUTHOR,
+ PLUGIN_DESCRIPTION,
+ PLUGIN_LICENSE,
+ PLUGIN_MATURITY,
+ PLUGIN_AUTH_VERSION
+FROM INFORMATION_SCHEMA.PLUGINS
+ WHERE PLUGIN_TYPE='DATA TYPE'
+ AND PLUGIN_NAME='test_int8';
+--horizontal_results
+
+CREATE TABLE t1 (a TEST_INT8);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8(4));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8(10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8(20));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--disable_ps_protocol
+--enable_metadata
+SELECT CAST('100' AS TEST_INT8) AS cast;
+--disable_metadata
+--enable_ps_protocol
+
+--disable_ps_protocol
+--enable_metadata
+DELIMITER $$;
+BEGIN NOT ATOMIC
+ DECLARE a TEST_INT8 DEFAULT 256;
+ SELECT HEX(a), a;
+END;
+$$
+DELIMITER ;$$
+--disable_metadata
+--enable_ps_protocol
+
+CREATE FUNCTION f1(p TEST_INT8) RETURNS TEST_INT8 RETURN 1;
+SHOW CREATE FUNCTION f1;
+--disable_ps_protocol
+--enable_metadata
+SELECT f1(10);
+--disable_metadata
+--enable_ps_protocol
+DROP FUNCTION f1;
+
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT COALESCE(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT MIN(a), MAX(a) FROM t1;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (id INT, a TEST_INT8);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,1),(2,2);
+CREATE TABLE t2 AS SELECT id, MIN(a), MAX(a) FROM t1 GROUP BY id;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 AS SELECT DISTINCT a FROM t1;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT (SELECT a FROM t1) AS c1;
+--disable_ps_protocol
+--enable_metadata
+SELECT * FROM t2;
+--disable_metadata
+--enable_ps_protocol
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo # Testing CREATE..LIKE
+
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo # Testing CREATE..SELECT
+
+CREATE TABLE t1 (a TEST_INT8);
+CREATE TABLE t2 AS SELECT * FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+
+--echo # Testing ALTER
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (10),(20);
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY a INT;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY a TEST_INT8;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (10),(20);
+ALTER TABLE t1 ADD b TEST_INT8 DEFAULT 0;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo # Testing metadata views
+
+CREATE TABLE t1 (a TEST_INT8);
+--vertical_results
+SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+--horizontal_results
+SHOW COLUMNS FROM t1;
+DROP TABLE t1;
+
+
+--echo # Testing indexing
+
+CREATE TABLE t1 (a TEST_INT8, KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+EXPLAIN SELECT * FROM t1 WHERE a=3;
+DROP TABLE t1;
+
+--echo # Testing aggregation for result
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+ COALESCE(a,1) AS c1,
+ COALESCE(a,1.0) AS c2,
+ COALESCE(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ COALESCE(c,c_tinyint),
+ COALESCE(c,c_smallint),
+ COALESCE(c,c_mediumint),
+ COALESCE(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_time) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_date) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_datetime) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_timestamp) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_char) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_varchar) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_tinytext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_text) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_mediumtext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT COALESCE(c, c_longtext) FROM t1;
+DROP TABLE t1;
+
+--echo # Testing aggregation for min/max
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+ LEAST(a,1) AS c1,
+ LEAST(a,1.0) AS c2,
+ LEAST(a,1e0) AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ LEAST(c,c_tinyint),
+ LEAST(c,c_smallint),
+ LEAST(c,c_mediumint),
+ LEAST(c,c_bigint)
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_time) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_date) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_datetime) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_timestamp) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_char) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_varchar) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_tinytext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_text) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_mediumtext) FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT LEAST(c, c_longtext) FROM t1;
+DROP TABLE t1;
+
+
+--echo # Testing aggregation for numeric operation - plus
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7);
+CREATE TABLE t2 AS SELECT
+ a+1 AS c1,
+ a+1.0 AS c2,
+ a+1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ c + c_tinyint,
+ c + c_smallint,
+ c + c_mediumint,
+ c + c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_time FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_date FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_datetime FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_timestamp FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_char FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_varchar FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_tinytext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_text FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_mediumtext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c + c_longtext FROM t1;
+DROP TABLE t1;
+
+--echo # Testing aggregation for numeric operation - minus
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+CREATE TABLE t2 AS SELECT
+ a-1 AS c1,
+ a-1.0 AS c2,
+ a-1e0 AS c3
+FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2 ORDER BY c1;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_tinyint TINYINT,
+ c_smallint SMALLINT,
+ c_mediumint MEDIUMINT,
+ c_int INT,
+ c_bigint BIGINT
+);
+CREATE TABLE t2 AS SELECT
+ c - c_tinyint,
+ c - c_smallint,
+ c - c_mediumint,
+ c - c_bigint
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_time TIME,
+ c_date DATE,
+ c_datetime DATETIME,
+ c_timestamp TIMESTAMP
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_time FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_date FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_datetime FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_timestamp FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c TEST_INT8,
+ c_char CHAR(32),
+ c_varchar VARCHAR(32),
+ c_tinytext TINYTEXT,
+ c_text TEXT,
+ c_mediumtext MEDIUMTEXT,
+ c_longtext LONGTEXT
+);
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_char FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_varchar FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_tinytext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_text FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_mediumtext FROM t1;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT c - c_longtext FROM t1;
+DROP TABLE t1;
+
+
+--echo # Testing CAST to other data types
+
+CREATE TABLE t1 (a TEST_INT8);
+INSERT INTO t1 VALUES (20000102);
+CREATE TABLE t2 AS SELECT
+ a,
+ CAST(a AS CHAR),
+ CAST(a AS DECIMAL),
+ CAST(a AS DOUBLE),
+ CAST(a AS SIGNED),
+ CAST(a AS UNSIGNED),
+ CAST(a AS TIME),
+ CAST(a AS DATETIME),
+ CAST(a AS DATE)
+FROM t1;
+SHOW CREATE TABLE t2;
+--vertical_results
+SELECT * FROM t2;
+--horizontal_results
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_mysql.result b/plugin/type_test/mysql-test/type_test/type_test_mysql.result
new file mode 100644
index 00000000000..402e8265181
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_mysql.result
@@ -0,0 +1,27 @@
+CREATE TABLE t1 (a TEST_INT8, b TEST_DOUBLE);
+Field 1: `a`
+Catalog: `def`
+Database: `test`
+Table: `t1`
+Org_table: `t1`
+Type: LONGLONG
+Collation: binary (63)
+Length: 20
+Max_length: 0
+Decimals: 0
+Flags: NUM
+
+Field 2: `b`
+Catalog: `def`
+Database: `test`
+Table: `t1`
+Org_table: `t1`
+Type: DOUBLE
+Collation: binary (63)
+Length: 22
+Max_length: 0
+Decimals: 31
+Flags: NUM
+
+
+DROP TABLE t1;
diff --git a/plugin/type_test/mysql-test/type_test/type_test_mysql.test b/plugin/type_test/mysql-test/type_test/type_test_mysql.test
new file mode 100644
index 00000000000..95fafe67fb1
--- /dev/null
+++ b/plugin/type_test/mysql-test/type_test/type_test_mysql.test
@@ -0,0 +1,6 @@
+-- source include/have_working_dns.inc
+-- source include/not_embedded.inc
+
+CREATE TABLE t1 (a TEST_INT8, b TEST_DOUBLE);
+--exec $MYSQL -t test --column-type-info -e "SELECT * FROM t1" 2>&1
+DROP TABLE t1;
diff --git a/plugin/type_test/plugin.cc b/plugin/type_test/plugin.cc
new file mode 100644
index 00000000000..285cd202512
--- /dev/null
+++ b/plugin/type_test/plugin.cc
@@ -0,0 +1,343 @@
+/*
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2019, MariaDB
+
+ 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 <my_global.h>
+#include <sql_class.h> // THD
+#include <mysql/plugin_data_type.h>
+#include "sql_type.h"
+
+
+class Type_collection_test: public Type_collection
+{
+protected:
+ const Type_handler *aggregate_common(const Type_handler *h1,
+ const Type_handler *h2) const;
+public:
+ bool init(Type_handler_data *data) override
+ {
+ return false;
+ }
+ const Type_handler *handler_by_name(const LEX_CSTRING &name) const override
+ {
+ return NULL;
+ }
+ const Type_handler *aggregate_for_result(const Type_handler *h1,
+ const Type_handler *h2)
+ const override;
+ const Type_handler *aggregate_for_comparison(const Type_handler *h1,
+ const Type_handler *h2)
+ const override;
+ const Type_handler *aggregate_for_min_max(const Type_handler *h1,
+ const Type_handler *h2)
+ const override;
+ const Type_handler *aggregate_for_num_op(const Type_handler *h1,
+ const Type_handler *h2)
+ const override;
+};
+
+
+static Type_collection_test type_collection_test;
+
+
+class Field_test_int8 :public Field_longlong
+{
+public:
+ Field_test_int8(const LEX_CSTRING &name, const Record_addr &addr,
+ enum utype unireg_check_arg,
+ uint32 len_arg, bool zero_arg, bool unsigned_arg)
+ :Field_longlong(addr.ptr(), len_arg, addr.null_ptr(), addr.null_bit(),
+ Field::NONE, &name, zero_arg, unsigned_arg)
+ {}
+ const Type_handler *type_handler() const override;
+};
+
+
+class Type_handler_test_int8: public Type_handler_longlong
+{
+public:
+ const Name name() const override
+ {
+ static Name name(STRING_WITH_LEN("test_int8"));
+ return name;
+ }
+ const Type_collection *type_collection() const override
+ {
+ return &type_collection_test;
+ }
+ const Type_handler *type_handler_signed() const override
+ {
+ return this;
+ }
+ bool Column_definition_data_type_info_image(Binary_string *to,
+ const Column_definition &def)
+ const override
+ {
+ return to->append(Type_handler_test_int8::name().lex_cstring());
+ }
+ Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *root,
+ const LEX_CSTRING *name,
+ const Record_addr &rec, const Bit_addr &bit,
+ const Column_definition_attributes *attr,
+ uint32 flags) const override
+ {
+ return new (root)
+ Field_test_int8(*name, rec, attr->unireg_check,
+ (uint32) attr->length,
+ f_is_zerofill(attr->pack_flag) != 0,
+ f_is_dec(attr->pack_flag) == 0);
+ }
+};
+
+static Type_handler_test_int8 type_handler_test_int8;
+
+
+const Type_handler *Field_test_int8::type_handler() const
+{
+ return &type_handler_test_int8;
+}
+
+
+static struct st_mariadb_data_type plugin_descriptor_type_test_int8=
+{
+ MariaDB_DATA_TYPE_INTERFACE_VERSION,
+ &type_handler_test_int8
+};
+
+
+/*************************************************************************/
+
+class Field_test_double :public Field_double
+{
+public:
+ Field_test_double(const LEX_CSTRING &name, const Record_addr &addr,
+ enum utype unireg_check_arg,
+ uint32 len_arg, uint8 dec_arg,
+ bool zero_arg, bool unsigned_arg)
+ :Field_double(addr.ptr(), len_arg, addr.null_ptr(), addr.null_bit(),
+ Field::NONE, &name, dec_arg, zero_arg, unsigned_arg)
+ {}
+ const Type_handler *type_handler() const override;
+};
+
+
+class Type_handler_test_double: public Type_handler_double
+{
+public:
+ const Name name() const override
+ {
+ static Name name(STRING_WITH_LEN("test_double"));
+ return name;
+ }
+ const Type_collection *type_collection() const override
+ {
+ return &type_collection_test;
+ }
+ const Type_handler *type_handler_signed() const override
+ {
+ return this;
+ }
+ bool Column_definition_data_type_info_image(Binary_string *to,
+ const Column_definition &def)
+ const override
+ {
+ return to->append(Type_handler_test_double::name().lex_cstring());
+ }
+ Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *root,
+ const LEX_CSTRING *name,
+ const Record_addr &rec, const Bit_addr &bit,
+ const Column_definition_attributes *attr,
+ uint32 flags) const override
+ {
+ return new (root)
+ Field_test_double(*name, rec, attr->unireg_check,
+ (uint32) attr->length, (uint8) attr->decimals,
+ f_is_zerofill(attr->pack_flag) != 0,
+ f_is_dec(attr->pack_flag) == 0);
+ }
+};
+
+static Type_handler_test_double type_handler_test_double;
+
+
+const Type_handler *Field_test_double::type_handler() const
+{
+ return &type_handler_test_double;
+}
+
+
+static struct st_mariadb_data_type plugin_descriptor_type_test_double=
+{
+ MariaDB_DATA_TYPE_INTERFACE_VERSION,
+ &type_handler_test_double
+};
+
+
+/*************************************************************************/
+const Type_handler *
+Type_collection_test::aggregate_common(const Type_handler *h1,
+ const Type_handler *h2) const
+{
+ if (h1 == h2)
+ return h1;
+
+ static const Type_aggregator::Pair agg[]=
+ {
+ {
+ &type_handler_slong,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_newdecimal,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_double,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_slong,
+ &type_handler_test_int8,
+ &type_handler_test_int8
+ },
+ {
+ &type_handler_newdecimal,
+ &type_handler_test_int8,
+ &type_handler_newdecimal
+ },
+ {
+ &type_handler_double,
+ &type_handler_test_int8,
+ &type_handler_double
+ },
+ {
+ &type_handler_stiny,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_sshort,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_sint24,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_slonglong,
+ &type_handler_test_double,
+ &type_handler_test_double
+ },
+ {
+ &type_handler_stiny,
+ &type_handler_test_int8,
+ &type_handler_test_int8
+ },
+ {
+ &type_handler_sshort,
+ &type_handler_test_int8,
+ &type_handler_test_int8
+ },
+ {
+ &type_handler_sint24,
+ &type_handler_test_int8,
+ &type_handler_test_int8
+ },
+ {
+ &type_handler_slonglong,
+ &type_handler_test_int8,
+ &type_handler_test_int8
+ },
+ {NULL,NULL,NULL}
+ };
+
+ return Type_aggregator::find_handler_in_array(agg, h1, h2, true);
+}
+
+
+const Type_handler *
+Type_collection_test::aggregate_for_result(const Type_handler *h1,
+ const Type_handler *h2) const
+{
+ return aggregate_common(h1, h2);
+}
+
+
+const Type_handler *
+Type_collection_test::aggregate_for_min_max(const Type_handler *h1,
+ const Type_handler *h2) const
+{
+ return aggregate_common(h1, h2);
+}
+
+
+const Type_handler *
+Type_collection_test::aggregate_for_num_op(const Type_handler *h1,
+ const Type_handler *h2) const
+{
+ return aggregate_common(h1, h2);
+}
+
+
+const Type_handler *
+Type_collection_test::aggregate_for_comparison(const Type_handler *h1,
+ const Type_handler *h2) const
+{
+ DBUG_ASSERT(h1 == h1->type_handler_for_comparison());
+ DBUG_ASSERT(h2 == h2->type_handler_for_comparison());
+ return aggregate_common(h1, h2);
+}
+
+
+/*************************************************************************/
+
+maria_declare_plugin(type_test)
+{
+ MariaDB_DATA_TYPE_PLUGIN, // the plugin type (see include/mysql/plugin.h)
+ &plugin_descriptor_type_test_int8, // pointer to type-specific plugin descriptor
+ type_handler_test_int8.name().ptr(), // plugin name
+ "MariaDB Corporation", // plugin author
+ "Data type TEST_INT8", // the plugin description
+ PLUGIN_LICENSE_GPL, // the plugin license (see include/mysql/plugin.h)
+ 0, // Pointer to plugin initialization function
+ 0, // Pointer to plugin deinitialization function
+ 0x0100, // Numeric version 0xAABB means AA.BB veriosn
+ NULL, // Status variables
+ NULL, // System variables
+ "1.0", // String version representation
+ MariaDB_PLUGIN_MATURITY_EXPERIMENTAL // Maturity(see include/mysql/plugin.h)*/
+},
+{
+ MariaDB_DATA_TYPE_PLUGIN, // the plugin type (see include/mysql/plugin.h)
+ &plugin_descriptor_type_test_double, // pointer to type-specific plugin descriptor
+ type_handler_test_double.name().ptr(), // plugin name
+ "MariaDB Corporation", // plugin author
+ "Data type TEST_DOUBLE", // the plugin description
+ PLUGIN_LICENSE_GPL, // the plugin license (see include/mysql/plugin.h)
+ 0, // Pointer to plugin initialization function
+ 0, // Pointer to plugin deinitialization function
+ 0x0100, // Numeric version 0xAABB means AA.BB veriosn
+ NULL, // Status variables
+ NULL, // System variables
+ "1.0", // String version representation
+ MariaDB_PLUGIN_MATURITY_EXPERIMENTAL // Maturity(see include/mysql/plugin.h)*/
+}
+maria_declare_plugin_end;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index caccf27446b..c9db181fc65 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -945,7 +945,7 @@ bool is_native_function(THD *thd, const LEX_CSTRING *name)
if (is_lex_native_function(name))
return true;
- if (Type_handler::handler_by_name(*name))
+ if (Type_handler::handler_by_name(thd, *name))
return true;
return false;
@@ -10440,12 +10440,11 @@ bool LEX::set_field_type_udt(Lex_field_type_st *type,
const Lex_length_and_dec_st &attr)
{
const Type_handler *h;
- if (!(h= Type_handler::handler_by_name_or_error(name)))
+ if (!(h= Type_handler::handler_by_name_or_error(thd, name)))
return true;
type->set(h, attr);
charset= &my_charset_bin;
return false;
-
}
@@ -10453,7 +10452,7 @@ bool LEX::set_cast_type_udt(Lex_cast_type_st *type,
const LEX_CSTRING &name)
{
const Type_handler *h;
- if (!(h= Type_handler::handler_by_name_or_error(name)))
+ if (!(h= Type_handler::handler_by_name_or_error(thd, name)))
return true;
type->set(h);
charset= NULL;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 5fd3d0f0f6b..e957f63bb1e 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -38,6 +38,7 @@
#include <mysql/plugin_auth.h>
#include <mysql/plugin_password_validation.h>
#include <mysql/plugin_encryption.h>
+#include <mysql/plugin_data_type.h>
#include "sql_plugin_compat.h"
#ifdef HAVE_LINK_H
@@ -90,7 +91,8 @@ const LEX_CSTRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{ STRING_WITH_LEN("REPLICATION") },
{ STRING_WITH_LEN("AUTHENTICATION") },
{ STRING_WITH_LEN("PASSWORD VALIDATION") },
- { STRING_WITH_LEN("ENCRYPTION") }
+ { STRING_WITH_LEN("ENCRYPTION") },
+ { STRING_WITH_LEN("DATA TYPE") }
};
extern int initialize_schema_table(st_plugin_int *plugin);
@@ -110,13 +112,13 @@ extern int finalize_encryption_plugin(st_plugin_int *plugin);
plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
0, ha_initialize_handlerton, 0, 0,initialize_schema_table,
- initialize_audit_plugin, 0, 0, 0, initialize_encryption_plugin
+ initialize_audit_plugin, 0, 0, 0, initialize_encryption_plugin, 0
};
plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
0, ha_finalize_handlerton, 0, 0, finalize_schema_table,
- finalize_audit_plugin, 0, 0, 0, finalize_encryption_plugin
+ finalize_audit_plugin, 0, 0, 0, finalize_encryption_plugin, 0
};
/*
@@ -128,6 +130,7 @@ static int plugin_type_initialization_order[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
MYSQL_DAEMON_PLUGIN,
MariaDB_ENCRYPTION_PLUGIN,
+ MariaDB_DATA_TYPE_PLUGIN,
MYSQL_STORAGE_ENGINE_PLUGIN,
MYSQL_INFORMATION_SCHEMA_PLUGIN,
MYSQL_FTPARSER_PLUGIN,
@@ -169,7 +172,8 @@ static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
MYSQL_REPLICATION_INTERFACE_VERSION,
MIN_AUTHENTICATION_INTERFACE_VERSION,
MariaDB_PASSWORD_VALIDATION_INTERFACE_VERSION,
- MariaDB_ENCRYPTION_INTERFACE_VERSION
+ MariaDB_ENCRYPTION_INTERFACE_VERSION,
+ MariaDB_DATA_TYPE_INTERFACE_VERSION
};
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
@@ -182,7 +186,8 @@ static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
MYSQL_REPLICATION_INTERFACE_VERSION,
MYSQL_AUTHENTICATION_INTERFACE_VERSION,
MariaDB_PASSWORD_VALIDATION_INTERFACE_VERSION,
- MariaDB_ENCRYPTION_INTERFACE_VERSION
+ MariaDB_ENCRYPTION_INTERFACE_VERSION,
+ MariaDB_DATA_TYPE_INTERFACE_VERSION
};
static struct
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index f7e88686e7a..54b954d01f0 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -23,6 +23,7 @@
#include "item.h"
#include "log.h"
#include "tztime.h"
+#include <mysql/plugin_data_type.h>
const DTCollation &DTCollation_numeric::singleton()
@@ -189,8 +190,23 @@ bool Type_handler_data::init()
const Type_handler *
-Type_handler::handler_by_name(const LEX_CSTRING &name)
+Type_handler::handler_by_name(THD *thd, const LEX_CSTRING &name)
{
+ plugin_ref plugin;
+ if ((plugin= my_plugin_lock_by_name(thd, &name, MariaDB_DATA_TYPE_PLUGIN)))
+ {
+ /*
+ Data type plugins do not maintain ref_count yet.
+ For now we have only mandatory built-in plugins
+ and dynamic plugins for test purposes.
+ It should be safe to unlock the plugin immediately.
+ */
+ const Type_handler *ph= reinterpret_cast<st_mariadb_data_type*>
+ (plugin_decl(plugin)->info)->type_handler;
+ plugin_unlock(thd, plugin);
+ return ph;
+ }
+
#ifdef HAVE_SPATIAL
const Type_handler *ha= type_collection_geometry.handler_by_name(name);
if (ha)
@@ -213,9 +229,10 @@ static const Type_handler *frm_data_type_info_emulate(const LEX_CSTRING &name)
const Type_handler *
-Type_handler::handler_by_name_or_error(const LEX_CSTRING &name)
+Type_handler::handler_by_name_or_error(THD *thd, const LEX_CSTRING &name)
{
- const Type_handler *h= handler_by_name(name);
+ const Type_handler *h= handler_by_name(thd, name);
+ DBUG_EXECUTE_IF("emulate_handler_by_name_or_error_failure", h= NULL;);
if (!h)
{
DBUG_EXECUTE_IF("frm_data_type_info_emulate",
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 0fafcecd209..c2d93f69783 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -3329,8 +3329,9 @@ protected:
enum_field_types type)
const;
public:
- static const Type_handler *handler_by_name(const LEX_CSTRING &name);
- static const Type_handler *handler_by_name_or_error(const LEX_CSTRING &name);
+ static const Type_handler *handler_by_name(THD *thd, const LEX_CSTRING &name);
+ static const Type_handler *handler_by_name_or_error(THD *thd,
+ const LEX_CSTRING &name);
static const Type_handler *odbc_literal_type_handler(const LEX_CSTRING *str);
static const Type_handler *blob_type_handler(uint max_octet_length);
static const Type_handler *string_type_handler(uint max_octet_length);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 88b067ad16a..bf2e4231476 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -11262,7 +11262,7 @@ function_call_generic:
This will be revised with WL#2128 (SQL PATH)
*/
- if ((h= Type_handler::handler_by_name($1)) &&
+ if ((h= Type_handler::handler_by_name(thd, $1)) &&
(item= h->make_constructor_item(thd, $4)))
{
// Found a constructor with a proper argument count
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 3e39ee397c4..f0f80cef6ec 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -11361,7 +11361,7 @@ function_call_generic:
This will be revised with WL#2128 (SQL PATH)
*/
- if ((h= Type_handler::handler_by_name($1)) &&
+ if ((h= Type_handler::handler_by_name(thd, $1)) &&
(item= h->make_constructor_item(thd, $4)))
{
// Found a constructor with a proper argument count
diff --git a/sql/table.cc b/sql/table.cc
index 55ffc1142ea..958c5d77418 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2350,7 +2350,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (info.length)
{
- const Type_handler *h= Type_handler::handler_by_name_or_error(info);
+ const Type_handler *h= Type_handler::handler_by_name_or_error(thd,
+ info);
/*
This code will eventually be extended here:
- If the handler was not found by name, we could