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
8c0ec12b
Commit
8c0ec12b
authored
Jul 27, 2004
by
pekka@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NdbSqlUtil.cpp, NdbSqlUtil.hpp:
add NdbSqlUtil::cmp for missing datatypes
parent
345e1dc4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
22 deletions
+109
-22
ndb/include/util/NdbSqlUtil.hpp
ndb/include/util/NdbSqlUtil.hpp
+102
-15
ndb/src/common/util/NdbSqlUtil.cpp
ndb/src/common/util/NdbSqlUtil.cpp
+7
-7
No files found.
ndb/include/util/NdbSqlUtil.hpp
View file @
8c0ec12b
...
...
@@ -18,7 +18,7 @@
#define NDB_SQL_UTIL_HPP
#include <string.h>
#include <ndb_
types
.h>
#include <ndb_
global
.h>
#include <kernel/ndb_limits.h>
class
NdbSqlUtil
{
...
...
@@ -131,6 +131,7 @@ private:
inline
int
NdbSqlUtil
::
cmp
(
Uint32
typeId
,
const
Uint32
*
p1
,
const
Uint32
*
p2
,
Uint32
full
,
Uint32
size
)
{
// XXX require size >= 1
if
(
size
>
full
)
return
CmpError
;
switch
((
Type
::
Enum
)
typeId
)
{
...
...
@@ -192,10 +193,38 @@ NdbSqlUtil::cmp(Uint32 typeId, const Uint32* p1, const Uint32* p2, Uint32 full,
}
return
CmpUnknown
;
}
case
Type
:
:
Mediumint
:
// XXX fix these
break
;
case
Type
:
:
Mediumint
:
{
if
(
size
>=
1
)
{
union
{
const
Uint32
*
p
;
const
unsigned
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
;
u2
.
p
=
p2
;
Int32
v1
=
sint3korr
(
u1
.
v
);
Int32
v2
=
sint3korr
(
u2
.
v
);
if
(
v1
<
v2
)
return
-
1
;
if
(
v1
>
v2
)
return
+
1
;
return
0
;
}
return
CmpUnknown
;
}
case
Type
:
:
Mediumunsigned
:
break
;
{
if
(
size
>=
1
)
{
union
{
const
Uint32
*
p
;
const
unsigned
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
;
u2
.
p
=
p2
;
Uint32
v1
=
uint3korr
(
u1
.
v
);
Uint32
v2
=
uint3korr
(
u2
.
v
);
if
(
v1
<
v2
)
return
-
1
;
if
(
v1
>
v2
)
return
+
1
;
return
0
;
}
return
CmpUnknown
;
}
case
Type
:
:
Int
:
{
if
(
size
>=
1
)
{
...
...
@@ -287,6 +316,7 @@ NdbSqlUtil::cmp(Uint32 typeId, const Uint32* p1, const Uint32* p2, Uint32 full,
return
CmpUnknown
;
}
case
Type
:
:
Decimal
:
// XXX not used by MySQL or NDB
break
;
case
Type
:
:
Char
:
{
...
...
@@ -317,10 +347,28 @@ NdbSqlUtil::cmp(Uint32 typeId, const Uint32* p1, const Uint32* p2, Uint32 full,
}
return
CmpUnknown
;
}
case
Type
:
:
Binary
:
// XXX fix these
break
;
case
Type
:
:
Binary
:
{
// compare byte wise
union
{
const
Uint32
*
p
;
const
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
;
u2
.
p
=
p2
;
int
k
=
memcmp
(
u1
.
v
,
u2
.
v
,
size
<<
2
);
return
k
<
0
?
-
1
:
k
>
0
?
+
1
:
full
==
size
?
0
:
CmpUnknown
;
}
case
Type
:
:
Varbinary
:
break
;
{
// assume correctly padded and compare byte wise
if
(
size
>=
1
)
{
union
{
const
Uint32
*
p
;
const
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
;
u2
.
p
=
p2
;
// length in first 2 bytes
int
k
=
memcmp
(
u1
.
v
+
2
,
u2
.
v
+
2
,
(
size
<<
2
)
-
2
);
return
k
<
0
?
-
1
:
k
>
0
?
+
1
:
full
==
size
?
0
:
CmpUnknown
;
}
return
CmpUnknown
;
}
case
Type
:
:
Datetime
:
{
/*
...
...
@@ -331,19 +379,57 @@ NdbSqlUtil::cmp(Uint32 typeId, const Uint32* p1, const Uint32* p2, Uint32 full,
u1
.
p
=
p1
;
u2
.
p
=
p2
;
// skip format check
int
k
=
strn
cmp
(
u1
.
v
,
u2
.
v
,
4
);
int
k
=
mem
cmp
(
u1
.
v
,
u2
.
v
,
4
);
if
(
k
!=
0
)
return
k
;
return
k
<
0
?
-
1
:
+
1
;
if
(
size
>=
2
)
{
return
strncmp
(
u1
.
v
+
4
,
u2
.
v
+
4
,
4
);
k
=
memcmp
(
u1
.
v
+
4
,
u2
.
v
+
4
,
4
);
return
k
<
0
?
-
1
:
k
>
0
?
+
1
:
0
;
}
}
return
CmpUnknown
;
}
case
Type
:
:
Timespec
:
// XXX fix this
break
;
case
Type
:
:
Blob
:
// XXX fix
break
;
case
Type
:
:
Timespec
:
{
/*
* Timespec is CC YY MM DD hh mm ss \0 NN NN NN NN
*/
if
(
size
>=
1
)
{
union
{
const
Uint32
*
p
;
const
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
;
u2
.
p
=
p2
;
// skip format check
int
k
=
memcmp
(
u1
.
v
,
u2
.
v
,
4
);
if
(
k
!=
0
)
return
k
<
0
?
-
1
:
+
1
;
if
(
size
>=
2
)
{
k
=
memcmp
(
u1
.
v
+
4
,
u2
.
v
+
4
,
4
);
if
(
k
!=
0
)
return
k
<
0
?
-
1
:
+
1
;
Uint32
n1
=
*
(
const
Uint32
*
)(
u1
.
v
+
8
);
Uint32
n2
=
*
(
const
Uint32
*
)(
u2
.
v
+
8
);
if
(
n1
<
n2
)
return
-
1
;
if
(
n2
>
n1
)
return
+
1
;
return
0
;
}
}
return
CmpUnknown
;
}
case
Type
:
:
Blob
:
{
// skip blob head, the rest is binary
const
unsigned
skip
=
NDB_BLOB_HEAD_SIZE
;
if
(
size
>=
skip
+
1
)
{
union
{
const
Uint32
*
p
;
const
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
+
skip
;
u2
.
p
=
p2
+
skip
;
int
k
=
memcmp
(
u1
.
v
,
u2
.
v
,
(
size
-
1
)
<<
2
);
return
k
<
0
?
-
1
:
k
>
0
?
+
1
:
full
==
size
?
0
:
CmpUnknown
;
}
return
CmpUnknown
;
}
case
Type
:
:
Text
:
{
// skip blob head, the rest is char
...
...
@@ -352,7 +438,8 @@ NdbSqlUtil::cmp(Uint32 typeId, const Uint32* p1, const Uint32* p2, Uint32 full,
union
{
const
Uint32
*
p
;
const
char
*
v
;
}
u1
,
u2
;
u1
.
p
=
p1
+
skip
;
u2
.
p
=
p2
+
skip
;
// TODO
int
k
=
memcmp
(
u1
.
v
,
u2
.
v
,
(
size
-
1
)
<<
2
);
return
k
<
0
?
-
1
:
k
>
0
?
+
1
:
full
==
size
?
0
:
CmpUnknown
;
}
return
CmpUnknown
;
}
...
...
ndb/src/common/util/NdbSqlUtil.cpp
View file @
8c0ec12b
...
...
@@ -98,11 +98,11 @@ NdbSqlUtil::m_typeList[] = {
},
{
Type
::
Mediumint
,
NULL
//
cmpMediumint
cmpMediumint
},
{
Type
::
Mediumunsigned
,
NULL
//
cmpMediumunsigned
cmpMediumunsigned
},
{
Type
::
Int
,
...
...
@@ -130,7 +130,7 @@ NdbSqlUtil::m_typeList[] = {
},
{
Type
::
Decimal
,
NULL
// cmpDecimal
NULL
// cmpDecimal
},
{
Type
::
Char
,
...
...
@@ -142,11 +142,11 @@ NdbSqlUtil::m_typeList[] = {
},
{
Type
::
Binary
,
NULL
//
cmpBinary
cmpBinary
},
{
Type
::
Varbinary
,
NULL
//
cmpVarbinary
cmpVarbinary
},
{
Type
::
Datetime
,
...
...
@@ -154,11 +154,11 @@ NdbSqlUtil::m_typeList[] = {
},
{
Type
::
Timespec
,
NULL
//
cmpTimespec
cmpTimespec
},
{
Type
::
Blob
,
NULL
// cmpDatetime
cmpBlob
},
{
Type
::
Text
,
...
...
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