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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
bcf8a344
Commit
bcf8a344
authored
Dec 23, 2004
by
mskold@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added bit field support for ndbcluster
parent
a32f231f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
14 deletions
+71
-14
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+71
-14
No files found.
sql/ha_ndbcluster.cc
View file @
bcf8a344
...
...
@@ -404,6 +404,7 @@ static inline bool ndb_supported_type(enum_field_types type)
case
MYSQL_TYPE_LONG_BLOB
:
case
MYSQL_TYPE_ENUM
:
case
MYSQL_TYPE_SET
:
case
MYSQL_TYPE_BIT
:
return
TRUE
;
case
MYSQL_TYPE_NULL
:
case
MYSQL_TYPE_GEOMETRY
:
...
...
@@ -483,13 +484,34 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field,
}
if
(
!
(
field
->
flags
&
BLOB_FLAG
))
{
if
(
field
->
is_null
())
// Set value to NULL
DBUG_RETURN
((
ndb_op
->
setValue
(
fieldnr
,
(
char
*
)
NULL
,
pack_len
)
!=
0
));
// Common implementation for most field types
DBUG_RETURN
(
ndb_op
->
setValue
(
fieldnr
,
(
char
*
)
field_ptr
,
pack_len
)
!=
0
);
if
(
field
->
type
()
!=
MYSQL_TYPE_BIT
)
{
if
(
field
->
is_null
())
// Set value to NULL
DBUG_RETURN
((
ndb_op
->
setValue
(
fieldnr
,
(
char
*
)
NULL
,
pack_len
)
!=
0
));
// Common implementation for most field types
DBUG_RETURN
(
ndb_op
->
setValue
(
fieldnr
,
(
char
*
)
field_ptr
,
pack_len
)
!=
0
);
}
else
// if (field->type() == MYSQL_TYPE_BIT)
{
char
buf
[
8
];
String
str
(
buf
,
(
uint32
)
sizeof
(
buf
),
NULL
);
if
(
pack_len
%
4
)
// Round up bit field length to nearest word boundry
pack_len
+=
4
-
(
pack_len
%
4
);
DBUG_ASSERT
(
pack_len
<=
8
);
if
(
field
->
is_null
())
// Set value to NULL
DBUG_RETURN
((
ndb_op
->
setValue
(
fieldnr
,
(
char
*
)
NULL
,
pack_len
)
!=
0
));
DBUG_PRINT
(
"info"
,
(
"bit field"
));
DBUG_DUMP
(
"value"
,
(
char
*
)
field
->
val_str
(
&
str
)
->
ptr
(),
pack_len
);
DBUG_RETURN
(
ndb_op
->
setValue
(
fieldnr
,
(
char
*
)
field
->
val_str
(
&
str
)
->
ptr
(),
pack_len
)
!=
0
);
}
}
// Blob type
NdbBlob
*
ndb_blob
=
ndb_op
->
getBlobHandle
(
fieldnr
);
if
(
ndb_blob
!=
NULL
)
...
...
@@ -624,13 +646,20 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field,
DBUG_ASSERT
(
field
->
ptr
!=
NULL
);
if
(
!
(
field
->
flags
&
BLOB_FLAG
))
{
byte
*
field_buf
;
if
(
field
->
pack_length
()
!=
0
)
field_buf
=
buf
+
(
field
->
ptr
-
table
->
record
[
0
]);
else
field_buf
=
(
byte
*
)
&
dummy_buf
;
m_value
[
fieldnr
].
rec
=
ndb_op
->
getValue
(
fieldnr
,
field_buf
);
if
(
field
->
type
()
!=
MYSQL_TYPE_BIT
)
{
byte
*
field_buf
;
if
(
field
->
pack_length
()
!=
0
)
field_buf
=
buf
+
(
field
->
ptr
-
table
->
record
[
0
]);
else
field_buf
=
(
byte
*
)
&
dummy_buf
;
m_value
[
fieldnr
].
rec
=
ndb_op
->
getValue
(
fieldnr
,
field_buf
);
}
else
// if (field->type() == MYSQL_TYPE_BIT)
{
m_value
[
fieldnr
].
rec
=
ndb_op
->
getValue
(
fieldnr
);
}
DBUG_RETURN
(
m_value
[
fieldnr
].
rec
==
NULL
);
}
...
...
@@ -2122,6 +2151,24 @@ void ha_ndbcluster::unpack_record(byte* buf)
{
if
((
*
value
).
rec
->
isNULL
())
(
*
field
)
->
set_null
(
row_offset
);
else
if
((
*
field
)
->
type
()
==
MYSQL_TYPE_BIT
)
{
uint
pack_len
=
(
*
field
)
->
pack_length
();
if
(
pack_len
<
5
)
{
DBUG_PRINT
(
"info"
,
(
"bit field H'%.8X"
,
(
*
value
).
rec
->
u_32_value
()));
((
Field_bit
*
)
*
field
)
->
store
((
longlong
)
(
*
value
).
rec
->
u_32_value
());
}
else
{
DBUG_PRINT
(
"info"
,
(
"bit field H'%.8X%.8X"
,
*
(
Uint32
*
)(
*
value
).
rec
->
aRef
(),
*
((
Uint32
*
)(
*
value
).
rec
->
aRef
()
+
1
)));
((
Field_bit
*
)
*
field
)
->
store
((
longlong
)
(
*
value
).
rec
->
u_64_value
());
}
}
}
else
{
...
...
@@ -3479,6 +3526,15 @@ static int create_ndb_column(NDBCOL &col,
col
.
setType
(
NDBCOL
::
Char
);
col
.
setLength
(
field
->
pack_length
());
break
;
case
MYSQL_TYPE_BIT
:
{
int
no_of_bits
=
field
->
field_length
*
8
+
((
Field_bit
*
)
field
)
->
bit_len
;
col
.
setType
(
NDBCOL
::
Bit
);
if
(
!
no_of_bits
)
col
.
setLength
(
1
);
else
col
.
setLength
(
no_of_bits
);
break
;
}
case
MYSQL_TYPE_NULL
:
case
MYSQL_TYPE_GEOMETRY
:
goto
mysql_type_unsupported
;
...
...
@@ -3843,7 +3899,8 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
HA_NULL_IN_KEY
|
HA_AUTO_PART_KEY
|
HA_NO_VARCHAR
|
HA_NO_PREFIX_CHAR_KEYS
),
HA_NO_PREFIX_CHAR_KEYS
|
HA_CAN_BIT_FIELD
),
m_share
(
0
),
m_use_write
(
FALSE
),
m_ignore_dup_key
(
FALSE
),
...
...
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