Skip to content

MDEV-38983 Add uuid_version() to uuid type#4732

Open
lefred wants to merge 6 commits into
MariaDB:mainfrom
lefred:uuid_version
Open

MDEV-38983 Add uuid_version() to uuid type#4732
lefred wants to merge 6 commits into
MariaDB:mainfrom
lefred:uuid_version

Conversation

@lefred

@lefred lefred commented Mar 4, 2026

Copy link
Copy Markdown

This patch adds uuid_version() function to uuid type

@CLAassistant

CLAassistant commented Mar 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@grooverdan grooverdan added the MariaDB Foundation Pull requests created by MariaDB Foundation label Mar 5, 2026

@grooverdan grooverdan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome @lefred.

Lets get a MDEV written, and some additional strictness with the UUID standards for a UUID_VERSION (which is pretty close to to what user's might expect a UUID_VALID function to perform).

Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test Outdated
Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test Outdated
Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/plugin.cc
Comment thread plugin/type_uuid/plugin.cc Outdated
@grooverdan

Copy link
Copy Markdown
Member

And correct Windows compiling error

@lefred lefred requested a review from grooverdan March 5, 2026 12:17
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test Outdated
Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test Outdated
Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
@grooverdan grooverdan self-requested a review March 24, 2026 00:17
@grooverdan grooverdan changed the title Add uuid_version() to uuid type MDEV-38983 Add uuid_version() to uuid type Mar 25, 2026

@grooverdan grooverdan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes:

  • white space change removal from non-changes coded
  • remove unnecessary if condition
  • rebase to main, squash up commits (removing merge commits), include MDEV, describe in detail what this implements. Describe UUIDv2 DCE deprecated in practice and lets see if anyone objects.
  • Testing ends with 13.1 now that 13.0 preview is out.

I tested with the following (AI assisted) that aided visualing all the version numbers. I think it helps be clear on coverage, include if you think so too.

CREATE TABLE t1 (id uuid PRIMARY KEY);

INSERT INTO t1 (id) VALUES
-- Version 1 (time-based)
('6ba7b810-9dad-11d1-80b4-00c04fd430c8'),
('f81d4fae-7dec-11d0-a765-00a0c91e6bf6'),

-- Version 3 (MD5 name-based)
('9073926b-929f-31c2-abc9-fad77ae3e8eb'),

-- Version 4 (random)
('550e8400-e29b-41d4-a716-446655440000'),
('123e4567-e89b-42d3-a456-426614174000'),
('ffffffff-ffff-4fff-bfff-ffffffffffff'),

-- Version 5 (SHA-1 name-based)
('2ed6657d-e927-568b-95e1-2665a8aea6a2'),

-- Version 6 (reordered time-based)
('1ec9414c-232a-6b00-b3c8-9e6bdecf3d2a'),
('1f0799c0-98b9-6f10-a2d3-5f6e7c8b9a01'),

-- Version 7 (Unix time + random)
('01890f4e-7b1a-7cc0-9f2a-6b5c4d3e2f10'),
('017f22e2-79b0-7a5b-b123-456789abcdef'),

-- Version 8 (custom / experimental)
('12345678-1234-8abc-8def-1234567890ab'),
('ffffffff-ffff-8fff-bfff-ffffffffffff'),

-- Boundary / edge patterns
('00000000-0000-4000-8000-000000000000'),
('aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa'),
('bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbbbb'),

-- Mixed / fuzz-like
('deadbeef-dead-4bad-8eed-feedfacecafe'),
('cafebabe-cafe-4abe-8afe-babecafebabe');

SELECT id,uuid_version(id) as v FROM t1 ORDER BY id;
TRUNCATE TABLE t1;

-- UUIDv2 - DCE
INSERT INTO t1 (id) VALUES
('000003e8-89ab-21d3-8c4d-001122334455'),
('000007d0-1234-2abc-9def-112233445566'),
('00000064-dead-2bad-a123-abcdefabcdef'),
('0000c350-beef-2345-b678-1234567890ab'),
('00000001-cafe-2ace-8ace-feedfacecafe');
SELECT id,uuid_version(id) as v FROM t1 ORDER BY id;

DROP TABLE t1;

Comment thread plugin/type_uuid/mysql-test/type_uuid/func_uuid_version.test
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.cc Outdated
Comment thread plugin/type_uuid/item_uuidfunc.h
@lefred lefred requested a review from grooverdan March 25, 2026 22:20
This patch adds a uuid_version() function to the uuid
datatype plugin. It validates the uuid and returns the version.

Based on practicialites - uuidv2 (DCE) generates a deprecated warnings:
 Warning	1300	Version 2 UUIDs are deprecated
{
my_printf_error(ER_INVALID_CHARACTER_STRING,
"Version 2 UUIDs are deprecated", ME_WARNING);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, remove this. UUIDv2 are not deprecated, and even if they were — they are not deprecated in MariaDB

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just removed it.

lefred added 5 commits June 1, 2026 10:12
Signed-off-by: Frederic Descamps <lefred@mariadb.org>
and error messages

Signed-off-by: Frederic Descamps <lefred@mariadb.org>
Update mtr
Add header and change validation function to be used by other functions

Signed-off-by: Frederic Descamps <lefredi@mariadb.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

4 participants