Commit 7ab11f2b authored by Alexander Barkov's avatar Alexander Barkov Committed by Sergei Golubchik

MDEV-4958 Adding datatype UUID

parent 72fb37ea
# Copyright (c) 2019,2021, MariaDB Corporation
#
# 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_uuid
plugin.cc sql_type_uuid.cc item_uuidfunc.cc
MANDATORY RECOMPILE_FOR_EMBEDDED)
/* Copyright (c) 2019,2021, MariaDB Corporation
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 */
#define MYSQL_SERVER
#include "mariadb.h"
#include "item_uuidfunc.h"
#include "sql_type_uuid.h"
class UUID_generated : public UUIDBundle::Fbt
{
public:
UUID_generated() { my_uuid((uchar *) m_buffer); }
bool to_string(String *to, bool with_separators) const
{
if (to->alloc(max_char_length() + 1))
return true;
to->set_charset(system_charset_info);
to->length(MY_UUID_BARE_STRING_LENGTH + with_separators*MY_UUID_SEPARATORS);
my_uuid2str((const uchar *) m_buffer, (char *) to->ptr(), with_separators);
return false;
}
};
String *Item_func_uuid::val_str(String *str)
{
DBUG_ASSERT(fixed());
if (!UUID_generated().to_string(str, with_separators))
return str;
str->set("", 0, collation.collation);
return str;
}
#ifndef ITEM_UUIDFUNC_INCLUDED
#define ITEM_UUIDFUNC_INCLUDED
/* Copyright (c) 2019,2021, MariaDB Corporation
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 */
#include "item.h"
class Item_func_uuid: public Item_str_func
{
bool with_separators;
public:
Item_func_uuid(THD *thd, bool with_separators_arg):
Item_str_func(thd), with_separators(with_separators_arg) {}
bool fix_length_and_dec()
{
collation.set(DTCollation_numeric());
fix_char_length(with_separators ? MY_UUID_STRING_LENGTH
: MY_UUID_BARE_STRING_LENGTH);
return FALSE;
}
bool const_item() const { return false; }
table_map used_tables() const { return RAND_TABLE_BIT; }
LEX_CSTRING func_name_cstring() const override
{
static LEX_CSTRING name1= {STRING_WITH_LEN("uuid") };
static LEX_CSTRING name2= {STRING_WITH_LEN("sys_guid") };
return with_separators ? name1 : name2;
}
String *val_str(String *);
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uuid>(thd, this); }
};
#endif // ITEM_UUIDFUNC_INCLUDED
#
# MDEV-4958 Adding datatype UUID
#
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000');
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff');
PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)';
EXECUTE stmt USING CAST('00000000-0000-0000-0000-000000000001' AS UUID);
EXECUTE stmt USING CAST(CONCAT(REPEAT(0x00,15), 0x02) AS UUID);
DEALLOCATE PREPARE stmt;
BEGIN NOT ATOMIC
DECLARE a UUID DEFAULT '00000000-0000-0000-0000-000000000003';
INSERT INTO t1 VALUES (a);
END;
$$
DROP TABLE t1;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a UUID)
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000001')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000002')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES ( NAME_CONST('a','00000000-0000-0000-0000-000000000003'))
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
--source include/not_embedded.inc
--source include/have_binlog_format_statement.inc
--disable_query_log
reset master; # get rid of previous tests binlog
--enable_query_log
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000');
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff');
PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)';
EXECUTE stmt USING CAST('00000000-0000-0000-0000-000000000001' AS UUID);
EXECUTE stmt USING CAST(CONCAT(REPEAT(0x00,15), 0x02) AS UUID);
DEALLOCATE PREPARE stmt;
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE a UUID DEFAULT '00000000-0000-0000-0000-000000000003';
INSERT INTO t1 VALUES (a);
END;
$$
DELIMITER ;$$
DROP TABLE t1;
--let $binlog_file = LAST
source include/show_binlog_events.inc;
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
# Using DEFAULT_CHARSET format
RESET MASTER;
SET GLOBAL binlog_row_metadata = NO_LOG;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES('123e4567-e89b-12d3-a456-426655440000');
# Columns(BINARY(16))
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = MINIMAL;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000');
# Columns(BINARY(16))
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = FULL;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000');
# Columns(`a` BINARY(16))
DROP TABLE t1;
RESET MASTER;
# Using COLUMN_CHARSET format
RESET MASTER;
SET GLOBAL binlog_row_metadata = NO_LOG;
CREATE TABLE t1 (a UUID, b CHAR(16) CHARACTER SET latin1, c CHAR(16) CHARACTER SET utf8);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000','','');
# Columns(BINARY(16),
# BINARY(16),
# BINARY(48))
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = MINIMAL;
CREATE TABLE t1 (a UUID, b CHAR(16) CHARACTER SET latin1, c CHAR(16) CHARACTER SET utf8);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000','','');
# Columns(BINARY(16),
# CHAR(16) CHARSET latin1 COLLATE latin1_swedish_ci,
# CHAR(16) CHARSET utf8mb3 COLLATE utf8mb3_general_ci)
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = FULL;
CREATE TABLE t1 (a UUID, b CHAR(16) CHARACTER SET latin1, c CHAR(16) CHARACTER SET utf8);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000','','');
# Columns(`a` BINARY(16),
# `b` CHAR(16) CHARSET latin1 COLLATE latin1_swedish_ci,
# `c` CHAR(16) CHARSET utf8mb3 COLLATE utf8mb3_general_ci)
DROP TABLE t1;
RESET MASTER;
SET GLOBAL binlog_row_metadata = DEFAULT;
#
# End of 10.5 tests
#
--source include/have_debug.inc
--source include/have_binlog_format_row.inc
--let $MYSQLD_DATADIR= `select @@datadir`
--let $binlog_file= $MYSQLD_DATADIR/master-bin.000001
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
--echo # Using DEFAULT_CHARSET format
RESET MASTER;
SET GLOBAL binlog_row_metadata = NO_LOG;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES('123e4567-e89b-12d3-a456-426655440000');
--source suite/binlog/include/print_optional_metadata.inc
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = MINIMAL;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000');
--source suite/binlog/include/print_optional_metadata.inc
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = FULL;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000');
--source suite/binlog/include/print_optional_metadata.inc
DROP TABLE t1;
RESET MASTER;
--echo # Using COLUMN_CHARSET format
RESET MASTER;
SET GLOBAL binlog_row_metadata = NO_LOG;
CREATE TABLE t1 (a UUID, b CHAR(16) CHARACTER SET latin1, c CHAR(16) CHARACTER SET utf8);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000','','');
--source suite/binlog/include/print_optional_metadata.inc
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = MINIMAL;
CREATE TABLE t1 (a UUID, b CHAR(16) CHARACTER SET latin1, c CHAR(16) CHARACTER SET utf8);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000','','');
--source suite/binlog/include/print_optional_metadata.inc
DROP TABLE t1;
RESET MASTER;
RESET MASTER;
SET GLOBAL binlog_row_metadata = FULL;
CREATE TABLE t1 (a UUID, b CHAR(16) CHARACTER SET latin1, c CHAR(16) CHARACTER SET utf8);
INSERT INTO t1 VALUES('12334567-8888-9999-aaaa-000000000000','','');
--source suite/binlog/include/print_optional_metadata.inc
DROP TABLE t1;
RESET MASTER;
SET GLOBAL binlog_row_metadata = DEFAULT;
--echo #
--echo # End of 10.5 tests
--echo #
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
SELECT
'----' AS `----`,
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='FUNCTION'
AND PLUGIN_NAME IN
('uuid')
ORDER BY PLUGIN_NAME;
---- ----
PLUGIN_NAME uuid
PLUGIN_VERSION 1.0
PLUGIN_STATUS ACTIVE
PLUGIN_TYPE FUNCTION
PLUGIN_AUTHOR MariaDB Corporation
PLUGIN_DESCRIPTION Function UUID()
PLUGIN_LICENSE GPL
PLUGIN_MATURITY Beta
PLUGIN_AUTH_VERSION 1.0
#
# End of 10.5 tests
#
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
--vertical_results
SELECT
'----' AS `----`,
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='FUNCTION'
AND PLUGIN_NAME IN
('uuid')
ORDER BY PLUGIN_NAME;
--horizontal_results
--echo #
--echo # End of 10.5 tests
--echo #
include/master-slave.inc
[connection master]
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
CREATE TABLE t1 (a BINARY(16));
connection slave;
ALTER TABLE t1 MODIFY a UUID;
connection master;
INSERT INTO t1 VALUES (X'00000000000000000000000000000000');
INSERT INTO t1 VALUES (X'00000000000000000000000000000001');
INSERT INTO t1 VALUES (X'fffffffffffffffffffffffffffffffe');
INSERT INTO t1 VALUES (X'ffffffffffffffffffffffffffffffff');
SELECT HEX(a) FROM t1 ORDER BY a;
HEX(a)
00000000000000000000000000000000
00000000000000000000000000000001
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
connection slave;
SELECT * FROM t1 ORDER BY a;
a
00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000001
ffffffff-ffff-ffff-ffff-fffffffffffe
ffffffff-ffff-ffff-ffff-ffffffffffff
connection master;
DROP TABLE t1;
#
# End of 10.5 tests
#
include/rpl_end.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
CREATE TABLE t1 (a BINARY(16));
--sync_slave_with_master
ALTER TABLE t1 MODIFY a UUID;
--connection master
INSERT INTO t1 VALUES (X'00000000000000000000000000000000');
INSERT INTO t1 VALUES (X'00000000000000000000000000000001');
INSERT INTO t1 VALUES (X'fffffffffffffffffffffffffffffffe');
INSERT INTO t1 VALUES (X'ffffffffffffffffffffffffffffffff');
SELECT HEX(a) FROM t1 ORDER BY a;
--sync_slave_with_master
SELECT * FROM t1 ORDER BY a;
--connection master
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
--source include/rpl_end.inc
include/master-slave.inc
[connection master]
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
CREATE TABLE t1 (a UUID);
connection slave;
ALTER TABLE t1 MODIFY a BINARY(16);
connection master;
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000');
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000001');
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-fffffffffffe');
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff');
SELECT a FROM t1 ORDER BY a;
a
00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000001
ffffffff-ffff-ffff-ffff-fffffffffffe
ffffffff-ffff-ffff-ffff-ffffffffffff
connection slave;
SELECT HEX(a) FROM t1 ORDER BY a;
HEX(a)
00000000000000000000000000000000
00000000000000000000000000000001
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
connection master;
DROP TABLE t1;
#
# End of 10.5 tests
#
include/rpl_end.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
CREATE TABLE t1 (a UUID);
--sync_slave_with_master
ALTER TABLE t1 MODIFY a BINARY(16);
--connection master
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000');
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000001');
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-fffffffffffe');
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff');
SELECT a FROM t1 ORDER BY a;
--sync_slave_with_master
SELECT HEX(a) FROM t1 ORDER BY a;
--connection master
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
--source include/rpl_end.inc
include/master-slave.inc
[connection master]
#
# MDEV-4958 Adding datatype UUID
#
connection master;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES
('00000000-0000-0000-0000-000000000000'),
('ffffffff-ffff-ffff-ffff-ffffffffffff');
connection slave;
SELECT HEX(a), a FROM t1;
HEX(a) a
00000000000000000000000000000000 00000000-0000-0000-0000-000000000000
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ffffffff-ffff-ffff-ffff-ffffffffffff
connection master;
DROP TABLE t1;
connection slave;
include/rpl_end.inc
--source include/master-slave.inc
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
connection master;
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES
('00000000-0000-0000-0000-000000000000'),
('ffffffff-ffff-ffff-ffff-ffffffffffff');
sync_slave_with_master;
SELECT HEX(a), a FROM t1;
connection master;
DROP TABLE t1;
sync_slave_with_master;
--source include/rpl_end.inc
package My::Suite::Type_uuid;
@ISA = qw(My::Suite);
sub is_default { 1 }
bless { };
#
# MDEV-4958 Adding datatype UUID
#
SET @old_debug_dbug=@@debug_dbug;
SET debug_dbug="+d,frm_data_type_info";
CREATE TABLE t1 (c01 UUID, c02 UUID);
Warnings:
Note 1105 build_frm_image: Field data type info length: 12
Note 1105 DBUG: [0] name='c01' type_info='uuid'
Note 1105 DBUG: [1] name='c02' type_info='uuid'
SET debug_dbug=@old_debug_dbug;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c01` uuid DEFAULT NULL,
`c02` uuid DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
--source include/have_debug.inc
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
SET @old_debug_dbug=@@debug_dbug;
SET debug_dbug="+d,frm_data_type_info";
CREATE TABLE t1 (c01 UUID, c02 UUID);
SET debug_dbug=@old_debug_dbug;
SHOW CREATE TABLE t1;
DROP TABLE t1;
This diff is collapsed.
This diff is collapsed.
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
SET default_storage_engine=CSV;
CREATE TABLE t1 (a UUID NOT NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid NOT NULL
) ENGINE=CSV DEFAULT CHARSET=latin1
FOR i IN 0..255
DO
INSERT INTO t1 VALUES (CONCAT(REPEAT(0x00,15), UNHEX(HEX(i))));
END FOR
$$
SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
a
00000000-0000-0000-0000-0000000000ff
SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe' ORDER BY a;
a
00000000-0000-0000-0000-0000000000fe
00000000-0000-0000-0000-0000000000ff
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000ff'
)
ORDER BY a;
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
00000000-0000-0000-0000-0000000000ff
SELECT * FROM t1
WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080'
AND
'00000000-0000-0000-0000-000000000081'
ORDER BY a;
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-000000000081
SELECT CONCAT('ffff',SUBSTRING(a, 5,256)) FROM t1 WHERE a LIKE '%a_';
CONCAT('ffff',SUBSTRING(a, 5,256))
ffff0000-0000-0000-0000-0000000000a0
ffff0000-0000-0000-0000-0000000000a1
ffff0000-0000-0000-0000-0000000000a2
ffff0000-0000-0000-0000-0000000000a3
ffff0000-0000-0000-0000-0000000000a4
ffff0000-0000-0000-0000-0000000000a5
ffff0000-0000-0000-0000-0000000000a6
ffff0000-0000-0000-0000-0000000000a7
ffff0000-0000-0000-0000-0000000000a8
ffff0000-0000-0000-0000-0000000000a9
ffff0000-0000-0000-0000-0000000000aa
ffff0000-0000-0000-0000-0000000000ab
ffff0000-0000-0000-0000-0000000000ac
ffff0000-0000-0000-0000-0000000000ad
ffff0000-0000-0000-0000-0000000000ae
ffff0000-0000-0000-0000-0000000000af
UPDATE t1 SET a=CONCAT('ffff',SUBSTRING(a, 5,256)) WHERE a LIKE '%a_';
SELECT * FROM t1 WHERE a LIKE 'ffff%' ORDER BY a;
a
ffff0000-0000-0000-0000-0000000000a0
ffff0000-0000-0000-0000-0000000000a1
ffff0000-0000-0000-0000-0000000000a2
ffff0000-0000-0000-0000-0000000000a3
ffff0000-0000-0000-0000-0000000000a4
ffff0000-0000-0000-0000-0000000000a5
ffff0000-0000-0000-0000-0000000000a6
ffff0000-0000-0000-0000-0000000000a7
ffff0000-0000-0000-0000-0000000000a8
ffff0000-0000-0000-0000-0000000000a9
ffff0000-0000-0000-0000-0000000000aa
ffff0000-0000-0000-0000-0000000000ab
ffff0000-0000-0000-0000-0000000000ac
ffff0000-0000-0000-0000-0000000000ad
ffff0000-0000-0000-0000-0000000000ae
ffff0000-0000-0000-0000-0000000000af
DROP TABLE t1;
CREATE TABLE t1 (a UUID NOT NULL) ENGINE=CSV;
INSERT INTO t1 VALUES ('123e4567-e89b-12d3-a456-426655440000');
SELECT * FROM t1;
a
123e4567-e89b-12d3-a456-426655440000
DROP TABLE t1;
#
# End of 10.5 tests
#
--source include/have_csv.inc
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
SET default_storage_engine=CSV;
CREATE TABLE t1 (a UUID NOT NULL);
SHOW CREATE TABLE t1;
DELIMITER $$;
FOR i IN 0..255
DO
INSERT INTO t1 VALUES (CONCAT(REPEAT(0x00,15), UNHEX(HEX(i))));
END FOR
$$
DELIMITER ;$$
SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe' ORDER BY a;
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000ff'
)
ORDER BY a;
SELECT * FROM t1
WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080'
AND
'00000000-0000-0000-0000-000000000081'
ORDER BY a;
SELECT CONCAT('ffff',SUBSTRING(a, 5,256)) FROM t1 WHERE a LIKE '%a_';
UPDATE t1 SET a=CONCAT('ffff',SUBSTRING(a, 5,256)) WHERE a LIKE '%a_';
SELECT * FROM t1 WHERE a LIKE 'ffff%' ORDER BY a;
DROP TABLE t1;
CREATE TABLE t1 (a UUID NOT NULL) ENGINE=CSV;
INSERT INTO t1 VALUES ('123e4567-e89b-12d3-a456-426655440000');
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # Range optimizer
--echo #
CREATE TABLE t1 (a UUID, INDEX(a));
SHOW CREATE TABLE t1;
DELIMITER $$;
FOR i IN 0..255
DO
INSERT INTO t1 VALUES (CONCAT(REPEAT(0x00, 15),CHAR(i USING BINARY)));
END FOR
$$
DELIMITER ;$$
SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
EXPLAIN SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
SELECT * FROM t1 WHERE a='garbage';
EXPLAIN SELECT * FROM t1 WHERE a='garbage';
SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
EXPLAIN SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
SELECT * FROM t1 WHERE a>='garbage';
EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
DROP TABLE t1;
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
SET default_storage_engine=InnoDB;
#
# Range optimizer
#
CREATE TABLE t1 (a UUID, INDEX(a));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
FOR i IN 0..255
DO
INSERT INTO t1 VALUES (CONCAT(REPEAT(0x00, 15),CHAR(i USING BINARY)));
END FOR
$$
SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
a
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 17 const 1 Using where; Using index
SELECT * FROM t1 WHERE a='garbage';
a
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a='garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
a
00000000-0000-0000-0000-0000000000fe
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a>='garbage';
a
EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
00000000-0000-0000-0000-0000000000f0
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-000000000081
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
a
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
a
00000000-0000-0000-0000-0000000000ff
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref a a 17 const 1 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = UUID'00000000-0000-0000-0000-0000000000ff'
DROP TABLE t1;
#
# End of 10.5 tests
#
--source include/have_innodb.inc
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
SET default_storage_engine=InnoDB;
--source type_uuid_engines.inc
--echo #
--echo # End of 10.5 tests
--echo #
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
SET default_storage_engine=MEMORY;
#
# Range optimizer
#
CREATE TABLE t1 (a UUID, INDEX(a));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1
FOR i IN 0..255
DO
INSERT INTO t1 VALUES (CONCAT(REPEAT(0x00, 15),CHAR(i USING BINARY)));
END FOR
$$
SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
a
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 17 const 2 Using where
SELECT * FROM t1 WHERE a='garbage';
a
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a='garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
a
00000000-0000-0000-0000-0000000000fe
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 256 Using where
SELECT * FROM t1 WHERE a>='garbage';
a
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 256 Using where
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
00000000-0000-0000-0000-0000000000f0
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 6 Using where
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 4 Using where
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-000000000081
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 256 Using where
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
a
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 256 Using where
SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
a
00000000-0000-0000-0000-0000000000ff
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref a a 17 const 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = UUID'00000000-0000-0000-0000-0000000000ff'
DROP TABLE t1;
#
# End of 10.5 tests
#
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
SET default_storage_engine=MEMORY;
--source type_uuid_engines.inc
--echo #
--echo # End of 10.5 tests
--echo #
#
# Start of 10.5 tests
#
#
# MDEV-4958 Adding datatype UUID
#
SET default_storage_engine=MyISAM;
#
# Range optimizer
#
CREATE TABLE t1 (a UUID, INDEX(a));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
FOR i IN 0..255
DO
INSERT INTO t1 VALUES (CONCAT(REPEAT(0x00, 15),CHAR(i USING BINARY)));
END FOR
$$
SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
a
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 17 const 1 Using where; Using index
SELECT * FROM t1 WHERE a='garbage';
a
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a='garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
a
00000000-0000-0000-0000-0000000000fe
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a>='garbage';
a
EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
00000000-0000-0000-0000-0000000000f0
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'00000000-0000-0000-0000-0000000000f0'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-0000000000a0
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
EXPLAIN SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
'00000000-0000-0000-0000-0000000000a0',
'garbage'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
a
00000000-0000-0000-0000-000000000080
00000000-0000-0000-0000-000000000081
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
a
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
a
00000000-0000-0000-0000-0000000000ff
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref a a 17 const 1 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = UUID'00000000-0000-0000-0000-0000000000ff'
DROP TABLE t1;
#
# End of 10.5 tests
#
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
SET default_storage_engine=MyISAM;
--source type_uuid_engines.inc
--echo #
--echo # End of 10.5 tests
--echo #
CREATE TABLE t1 (a UUID);
Field 1: `a`
Catalog: `def`
Database: `test`
Table: `t1`
Org_table: `t1`
Type: STRING (type=uuid)
Collation: latin1_swedish_ci (8)
Length: 36
Max_length: 0
Decimals: 0
Flags: UNSIGNED BINARY
DROP TABLE t1;
-- source include/have_working_dns.inc
-- source include/not_embedded.inc
CREATE TABLE t1 (a UUID);
--exec $MYSQL -t test --column-type-info -e "SELECT * FROM t1" 2>&1
DROP TABLE t1;
#
# MDEV-4958 Adding datatype UUID
#
SET NAMES utf8;
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN (10));
ERROR HY000: Partition column values of incorrect type
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN (TIME'10:20:30'));
ERROR HY000: Partition column values of incorrect type
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN ('€'));
ERROR 22007: Incorrect uuid value: '€'
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN ('123e4567-e89b-12d3-a456-426655440000'),
PARTITION pFF VALUES IN (0xffff000000000000000000000000ffff));
INSERT INTO t1 VALUES ('123e4567-e89b-12d3-a456-426655440000');
INSERT INTO t1 VALUES ('ffff0000-0000-0000-0000-00000000ffff');
SELECT * FROM t1 PARTITION (p00);
a
123e4567-e89b-12d3-a456-426655440000
SELECT * FROM t1 PARTITION (pFF);
a
ffff0000-0000-0000-0000-00000000ffff
DROP TABLE t1;
--source include/have_partition.inc
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
SET NAMES utf8;
--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN (10));
--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN (TIME'10:20:30'));
--error ER_TRUNCATED_WRONG_VALUE
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN ('€'));
CREATE TABLE t1 (a UUID)
PARTITION BY LIST COLUMNS(a)
(PARTITION p00 VALUES IN ('123e4567-e89b-12d3-a456-426655440000'),
PARTITION pFF VALUES IN (0xffff000000000000000000000000ffff));
INSERT INTO t1 VALUES ('123e4567-e89b-12d3-a456-426655440000');
INSERT INTO t1 VALUES ('ffff0000-0000-0000-0000-00000000ffff');
SELECT * FROM t1 PARTITION (p00);
SELECT * FROM t1 PARTITION (pFF);
DROP TABLE t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment