Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8bf25f3f
Commit
8bf25f3f
authored
May 06, 2023
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: remove sql_type_uuid.cc
this is a necessary prerequisite for making UUID itself a template
parent
f3bacd70
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
121 deletions
+90
-121
plugin/type_uuid/CMakeLists.txt
plugin/type_uuid/CMakeLists.txt
+1
-1
plugin/type_uuid/sql_type_uuid.cc
plugin/type_uuid/sql_type_uuid.cc
+0
-117
plugin/type_uuid/sql_type_uuid.h
plugin/type_uuid/sql_type_uuid.h
+89
-3
No files found.
plugin/type_uuid/CMakeLists.txt
View file @
8bf25f3f
...
...
@@ -14,5 +14,5 @@
# 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
plugin.cc item_uuidfunc.cc
MANDATORY RECOMPILE_FOR_EMBEDDED
)
plugin/type_uuid/sql_type_uuid.cc
deleted
100644 → 0
View file @
f3bacd70
/* 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 "my_net.h"
#include "sql_class.h" // THD, SORT_FIELD_ATTR
#include "opt_range.h" // SEL_ARG
#include "sql_type_uuid.h"
static
bool
get_digit
(
char
ch
,
uint
*
val
)
{
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
{
*
val
=
(
uint
)
ch
-
'0'
;
return
false
;
}
if
(
ch
>=
'a'
&&
ch
<=
'f'
)
{
*
val
=
(
uint
)
ch
-
'a'
+
0x0a
;
return
false
;
}
if
(
ch
>=
'A'
&&
ch
<=
'F'
)
{
*
val
=
(
uint
)
ch
-
'A'
+
0x0a
;
return
false
;
}
return
true
;
}
static
bool
get_digit
(
uint
*
val
,
const
char
*
str
,
const
char
*
end
)
{
if
(
str
>=
end
)
return
true
;
return
get_digit
(
*
str
,
val
);
}
static
size_t
skip_hyphens
(
const
char
*
str
,
const
char
*
end
)
{
const
char
*
str0
=
str
;
for
(
;
str
<
end
;
str
++
)
{
if
(
str
[
0
]
!=
'-'
)
break
;
}
return
str
-
str0
;
}
static
const
char
*
get_two_digits
(
char
*
val
,
const
char
*
str
,
const
char
*
end
)
{
uint
hi
,
lo
;
if
(
get_digit
(
&
hi
,
str
++
,
end
))
return
NULL
;
str
+=
skip_hyphens
(
str
,
end
);
if
(
get_digit
(
&
lo
,
str
++
,
end
))
return
NULL
;
*
val
=
(
char
)
((
hi
<<
4
)
+
lo
);
return
str
;
}
bool
UUID
::
ascii_to_fbt
(
const
char
*
str
,
size_t
str_length
)
{
const
char
*
end
=
str
+
str_length
;
/*
The format understood:
- Hyphen is not allowed on the first and the last position.
- Otherwise, hyphens are allowed on any (odd and even) position,
with any amount.
*/
if
(
str_length
<
32
)
goto
err
;
for
(
uint
oidx
=
0
;
oidx
<
binary_length
();
oidx
++
)
{
if
(
!
(
str
=
get_two_digits
(
&
m_buffer
[
oidx
],
str
,
end
)))
goto
err
;
// Allow hypheps after two digits, but not after the last digit
if
(
oidx
+
1
<
binary_length
())
str
+=
skip_hyphens
(
str
,
end
);
}
if
(
str
<
end
)
goto
err
;
// Some input left
return
false
;
err:
bzero
(
m_buffer
,
sizeof
(
m_buffer
));
return
true
;
}
size_t
UUID
::
to_string
(
char
*
dst
,
size_t
dstsize
)
const
{
my_uuid2str
((
const
uchar
*
)
m_buffer
,
dst
,
1
);
return
MY_UUID_STRING_LENGTH
;
}
const
Name
&
UUID
::
default_value
()
{
static
Name
def
(
STRING_WITH_LEN
(
"00000000-0000-0000-0000-000000000000"
));
return
def
;
}
plugin/type_uuid/sql_type_uuid.h
View file @
8bf25f3f
...
...
@@ -19,11 +19,97 @@
#include "sql_type_fixedbin_storage.h"
class
UUID
:
public
FixedBinTypeStorage
<
MY_UUID_SIZE
,
MY_UUID_STRING_LENGTH
>
{
bool
get_digit
(
char
ch
,
uint
*
val
)
{
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
{
*
val
=
(
uint
)
ch
-
'0'
;
return
false
;
}
if
(
ch
>=
'a'
&&
ch
<=
'f'
)
{
*
val
=
(
uint
)
ch
-
'a'
+
0x0a
;
return
false
;
}
if
(
ch
>=
'A'
&&
ch
<=
'F'
)
{
*
val
=
(
uint
)
ch
-
'A'
+
0x0a
;
return
false
;
}
return
true
;
}
bool
get_digit
(
uint
*
val
,
const
char
*
str
,
const
char
*
end
)
{
if
(
str
>=
end
)
return
true
;
return
get_digit
(
*
str
,
val
);
}
size_t
skip_hyphens
(
const
char
*
str
,
const
char
*
end
)
{
const
char
*
str0
=
str
;
for
(
;
str
<
end
;
str
++
)
{
if
(
str
[
0
]
!=
'-'
)
break
;
}
return
str
-
str0
;
}
const
char
*
get_two_digits
(
char
*
val
,
const
char
*
str
,
const
char
*
end
)
{
uint
hi
,
lo
;
if
(
get_digit
(
&
hi
,
str
++
,
end
))
return
NULL
;
str
+=
skip_hyphens
(
str
,
end
);
if
(
get_digit
(
&
lo
,
str
++
,
end
))
return
NULL
;
*
val
=
(
char
)
((
hi
<<
4
)
+
lo
);
return
str
;
}
public:
using
FixedBinTypeStorage
::
FixedBinTypeStorage
;
bool
ascii_to_fbt
(
const
char
*
str
,
size_t
str_length
);
size_t
to_string
(
char
*
dst
,
size_t
dstsize
)
const
;
static
const
Name
&
default_value
();
bool
ascii_to_fbt
(
const
char
*
str
,
size_t
str_length
)
{
const
char
*
end
=
str
+
str_length
;
/*
The format understood:
- Hyphen is not allowed on the first and the last position.
- Otherwise, hyphens are allowed on any (odd and even) position,
with any amount.
*/
if
(
str_length
<
32
)
goto
err
;
for
(
uint
oidx
=
0
;
oidx
<
binary_length
();
oidx
++
)
{
if
(
!
(
str
=
get_two_digits
(
&
m_buffer
[
oidx
],
str
,
end
)))
goto
err
;
// Allow hypheps after two digits, but not after the last digit
if
(
oidx
+
1
<
binary_length
())
str
+=
skip_hyphens
(
str
,
end
);
}
if
(
str
<
end
)
goto
err
;
// Some input left
return
false
;
err:
bzero
(
m_buffer
,
sizeof
(
m_buffer
));
return
true
;
}
size_t
to_string
(
char
*
dst
,
size_t
dstsize
)
const
{
my_uuid2str
((
const
uchar
*
)
m_buffer
,
dst
,
1
);
return
MY_UUID_STRING_LENGTH
;
}
static
const
Name
&
default_value
()
{
static
Name
def
(
STRING_WITH_LEN
(
"00000000-0000-0000-0000-000000000000"
));
return
def
;
}
/*
Binary (in-memory) UUIDv1 representation:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment