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
7f9b3ea9
Commit
7f9b3ea9
authored
Mar 24, 2020
by
Nikita Malyavin
Committed by
Sergei Golubchik
Mar 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass ptr into more Field methods
parent
6334b576
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
47 deletions
+76
-47
sql/field.cc
sql/field.cc
+28
-22
sql/field.h
sql/field.h
+41
-20
sql/sql_type_geom.cc
sql/sql_type_geom.cc
+5
-4
sql/sql_type_geom.h
sql/sql_type_geom.h
+2
-1
No files found.
sql/field.cc
View file @
7f9b3ea9
...
...
@@ -7530,12 +7530,13 @@ uint Field_string::max_packed_col_length(uint max_length)
}
uint
Field_string
::
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
uint
Field_string
::
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
{
size_t
bytes
=
field_charset
()
->
charpos
((
char
*
)
ptr
,
(
char
*
)
ptr
+
field_length
,
size_t
bytes
=
field_charset
()
->
charpos
((
char
*
)
ptr
_arg
,
(
char
*
)
ptr
_arg
+
field_length
,
length
/
mbmaxlen
());
memcpy
(
buff
,
ptr
,
bytes
);
memcpy
(
buff
,
ptr
_arg
,
bytes
);
if
(
bytes
<
length
)
field_charset
()
->
fill
((
char
*
)
buff
+
bytes
,
length
-
bytes
,
...
...
@@ -7915,18 +7916,19 @@ uint Field_varstring::max_packed_col_length(uint max_length)
return
(
max_length
>
255
?
2
:
1
)
+
max_length
;
}
void
Field_varstring
::
val_str_from_ptr
(
String
*
val
,
const
uchar
*
ptr
)
const
{
val
->
set
((
const
char
*
)
get_data
(
ptr
),
get_length
(
ptr
),
field_charset
());
}
uint
Field_varstring
::
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
{
String
val
;
uint
local_char_length
;
my_bitmap_map
*
old_map
;
old_map
=
dbug_tmp_use_all_columns
(
table
,
table
->
read_set
);
val_str
(
&
val
,
&
val
);
dbug_tmp_restore_column_map
(
table
->
read_set
,
old_map
);
val_str_from_ptr
(
&
val
,
ptr_arg
);
local_char_length
=
val
.
charpos
(
length
/
mbmaxlen
());
uint
local_char_length
=
val
.
charpos
(
length
/
mbmaxlen
());
if
(
local_char_length
<
val
.
length
())
val
.
length
(
local_char_length
);
/* Key is always stored with 2 bytes */
...
...
@@ -8172,6 +8174,11 @@ int Field_varstring_compressed::store(const char *from, size_t length,
return
rc
;
}
void
Field_varstring_compressed
::
val_str_from_ptr
(
String
*
val
,
const
uchar
*
ptr
)
const
{
uncompress
(
val
,
val
,
get_data
(
ptr
),
get_length
(
ptr
));
}
String
*
Field_varstring_compressed
::
val_str
(
String
*
val_buffer
,
String
*
val_ptr
)
{
...
...
@@ -8499,10 +8506,11 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr,
/* The following is used only when comparing a key */
uint
Field_blob
::
get_key_image_itRAW
(
uchar
*
buff
,
uint
length
)
uint
Field_blob
::
get_key_image_itRAW
(
const
uchar
*
ptr_arg
,
uchar
*
buff
,
uint
length
)
const
{
size_t
blob_length
=
get_length
(
ptr
);
uchar
*
blob
=
get_ptr
(
);
size_t
blob_length
=
get_length
(
ptr
_arg
);
const
uchar
*
blob
=
get_ptr
(
ptr_arg
);
size_t
local_char_length
=
length
/
mbmaxlen
();
local_char_length
=
field_charset
()
->
charpos
(
blob
,
blob
+
blob_length
,
local_char_length
);
...
...
@@ -8670,9 +8678,7 @@ void Field_blob::sql_type(String &res) const
uchar
*
Field_blob
::
pack
(
uchar
*
to
,
const
uchar
*
from
,
uint
max_length
)
{
uchar
*
save
=
ptr
;
ptr
=
(
uchar
*
)
from
;
uint32
length
=
get_length
();
// Length of from string
uint32
length
=
get_length
(
from
,
packlength
);
// Length of from string
/*
Store max length, which will occupy packlength bytes. If the max
...
...
@@ -8686,10 +8692,9 @@ uchar *Field_blob::pack(uchar *to, const uchar *from, uint max_length)
*/
if
(
length
>
0
)
{
from
=
get_ptr
();
from
=
get_ptr
(
from
);
memcpy
(
to
+
packlength
,
from
,
length
);
}
ptr
=
save
;
// Restore org row pointer
return
to
+
packlength
+
length
;
}
...
...
@@ -9706,11 +9711,12 @@ int Field_bit::cmp_offset(my_ptrdiff_t row_offset)
}
uint
Field_bit
::
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
uint
Field_bit
::
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
{
if
(
bit_len
)
{
uchar
bits
=
get_rec_bits
(
bit_ptr
,
bit_ofs
,
bit_len
);
const
uchar
*
bit_ptr_for_arg
=
ptr_arg
+
(
bit_ptr
-
ptr
);
uchar
bits
=
get_rec_bits
(
bit_ptr_for_arg
,
bit_ofs
,
bit_len
);
*
buff
++=
bits
;
length
--
;
}
...
...
sql/field.h
View file @
7f9b3ea9
...
...
@@ -1463,8 +1463,11 @@ class Field: public Value_source
if
(
null_ptr
)
null_ptr
=
ADD_TO_PTR
(
null_ptr
,
ptr_diff
,
uchar
*
);
}
virtual
void
get_image
(
uchar
*
buff
,
uint
length
,
CHARSET_INFO
*
cs
)
{
memcpy
(
buff
,
ptr
,
length
);
}
void
get_image
(
uchar
*
buff
,
uint
length
,
CHARSET_INFO
*
cs
)
const
{
get_image
(
buff
,
length
,
ptr
,
cs
);
}
virtual
void
get_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
CHARSET_INFO
*
cs
)
const
{
memcpy
(
buff
,
ptr_arg
,
length
);
}
virtual
void
set_image
(
const
uchar
*
buff
,
uint
length
,
CHARSET_INFO
*
cs
)
{
memcpy
(
ptr
,
buff
,
length
);
}
...
...
@@ -1495,9 +1498,11 @@ class Field: public Value_source
Number of copied bytes (excluding padded zero bytes -- see above).
*/
virtual
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
const
{
return
get_key_image
(
buff
,
length
,
ptr
,
type_arg
);
}
virtual
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
{
get_image
(
buff
,
length
,
&
my_charset_bin
);
get_image
(
buff
,
length
,
ptr_arg
,
&
my_charset_bin
);
return
length
;
}
virtual
void
set_key_image
(
const
uchar
*
buff
,
uint
length
)
...
...
@@ -3993,7 +3998,8 @@ class Field_string :public Field_longstr {
bool
has_charset
()
const
override
{
return
charset
()
!=
&
my_charset_bin
;
}
Field
*
make_new_field
(
MEM_ROOT
*
root
,
TABLE
*
new_table
,
bool
keep_type
)
override
;
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type
)
override
;
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type
)
const
override
;
sql_mode_t
value_depends_on_sql_mode
()
const
override
;
sql_mode_t
can_handle_sql_mode_dependency_on_store
()
const
override
;
void
print_key_value
(
String
*
out
,
uint32
length
)
override
;
...
...
@@ -4003,13 +4009,21 @@ class Field_string :public Field_longstr {
class
Field_varstring
:
public
Field_longstr
{
public:
uchar
*
get_data
()
const
const
uchar
*
get_data
()
const
{
return
ptr
+
length_bytes
;
return
get_data
(
ptr
);
}
const
uchar
*
get_data
(
const
uchar
*
ptr_arg
)
const
{
return
ptr_arg
+
length_bytes
;
}
uint
get_length
()
const
{
return
length_bytes
==
1
?
(
uint
)
*
ptr
:
uint2korr
(
ptr
);
return
get_length
(
ptr
);
}
uint
get_length
(
const
uchar
*
ptr_arg
)
const
{
return
length_bytes
==
1
?
(
uint
)
*
ptr_arg
:
uint2korr
(
ptr_arg
);
}
protected:
void
store_length
(
uint32
number
)
...
...
@@ -4019,6 +4033,7 @@ class Field_varstring :public Field_longstr {
else
int2store
(
ptr
,
number
);
}
virtual
void
val_str_from_ptr
(
String
*
val
,
const
uchar
*
ptr
)
const
;
public:
/*
The maximum space available in a Field_varstring, in bytes. See
...
...
@@ -4090,7 +4105,8 @@ class Field_varstring :public Field_longstr {
return
cmp_max
(
a
,
b
,
~
0U
);
}
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
;
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type
)
override
;
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type
)
const
override
;
void
set_key_image
(
const
uchar
*
buff
,
uint
length
)
override
;
void
sql_type
(
String
&
str
)
const
override
;
void
sql_rpl_type
(
String
*
)
const
override
;
...
...
@@ -4142,6 +4158,7 @@ class Field_varstring_compressed: public Field_varstring {
{
return
compression_method_ptr
;
}
private:
Compression_method
*
compression_method_ptr
;
void
val_str_from_ptr
(
String
*
val
,
const
uchar
*
ptr
)
const
override
;
int
store
(
const
char
*
to
,
size_t
length
,
CHARSET_INFO
*
charset
)
override
;
using
Field_str
::
store
;
String
*
val_str
(
String
*
,
String
*
)
override
;
...
...
@@ -4260,7 +4277,7 @@ class Field_blob :public Field_longstr {
static
void
do_copy_blob
(
Copy_field
*
copy
);
static
void
do_conv_blob
(
Copy_field
*
copy
);
uint
get_key_image_itRAW
(
uchar
*
buff
,
uint
length
)
;
uint
get_key_image_itRAW
(
const
uchar
*
ptr_arg
,
uchar
*
buff
,
uint
length
)
const
;
public:
Field_blob
(
uchar
*
ptr_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
enum
utype
unireg_check_arg
,
const
LEX_CSTRING
*
field_name_arg
,
...
...
@@ -4427,11 +4444,11 @@ class Field_blob :public Field_longstr {
uint32
get_length
(
const
uchar
*
ptr
,
uint
packlength
)
const
;
uint32
get_length
(
const
uchar
*
ptr_arg
)
const
{
return
get_length
(
ptr_arg
,
this
->
packlength
);
}
inline
uchar
*
get_ptr
()
const
{
return
get_ptr
(
0
);
}
inline
uchar
*
get_ptr
(
my_ptrdiff_t
row_offset
)
const
inline
uchar
*
get_ptr
()
const
{
return
get_ptr
(
ptr
);
}
inline
uchar
*
get_ptr
(
const
uchar
*
ptr_arg
)
const
{
uchar
*
s
;
memcpy
(
&
s
,
ptr
+
packlength
+
row_offset
,
sizeof
(
uchar
*
));
memcpy
(
&
s
,
ptr
_arg
+
packlength
,
sizeof
(
uchar
*
));
return
s
;
}
inline
void
set_ptr
(
uchar
*
length
,
uchar
*
data
)
...
...
@@ -4450,10 +4467,11 @@ class Field_blob :public Field_longstr {
set_ptr_offset
(
0
,
length
,
data
);
}
int
copy_value
(
Field_blob
*
from
);
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type
)
override
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type
)
const
override
{
DBUG_ASSERT
(
type
==
itRAW
);
return
get_key_image_itRAW
(
buff
,
length
);
return
get_key_image_itRAW
(
ptr_arg
,
buff
,
length
);
}
void
set_key_image
(
const
uchar
*
buff
,
uint
length
)
override
;
Field
*
new_key_field
(
MEM_ROOT
*
root
,
TABLE
*
new_table
,
...
...
@@ -4559,7 +4577,8 @@ class Field_blob_compressed: public Field_blob {
compression methods or compression levels.
*/
uint
get_key_image
(
uchar
*
,
uint
,
imagetype
)
override
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
override
{
DBUG_ASSERT
(
0
);
return
0
;
}
void
set_key_image
(
const
uchar
*
,
uint
)
override
{
DBUG_ASSERT
(
0
);
}
...
...
@@ -4846,15 +4865,17 @@ class Field_bit :public Field {
{
return
pos_in_interval_val_real
(
min
,
max
);
}
void
get_image
(
uchar
*
buff
,
uint
length
,
CHARSET_INFO
*
)
override
{
get_key_image
(
buff
,
length
,
itRAW
);
}
void
get_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
CHARSET_INFO
*
cs
)
const
override
{
get_key_image
(
buff
,
length
,
ptr_arg
,
itRAW
);
}
void
set_image
(
const
uchar
*
buff
,
uint
length
,
CHARSET_INFO
*
cs
)
override
{
Field_bit
::
store
((
char
*
)
buff
,
length
,
cs
);
}
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type
)
override
;
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type
)
const
override
;
void
set_key_image
(
const
uchar
*
buff
,
uint
length
)
override
{
Field_bit
::
store
((
char
*
)
buff
,
length
,
&
my_charset_bin
);
}
void
sort_string
(
uchar
*
buff
,
uint
length
)
override
{
get_key_image
(
buff
,
length
,
itRAW
);
}
{
get_key_image
(
buff
,
length
,
ptr
,
itRAW
);
}
uint32
pack_length
()
const
override
{
return
(
uint32
)
(
field_length
+
7
)
/
8
;
}
uint32
pack_length_in_rec
()
const
override
{
return
bytes_in_rec
;
}
...
...
sql/sql_type_geom.cc
View file @
7f9b3ea9
...
...
@@ -943,16 +943,17 @@ bool Field_geom::load_data_set_null(THD *thd)
}
uint
Field_geom
::
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
uint
Field_geom
::
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
{
if
(
type_arg
==
itMBR
)
{
LEX_CSTRING
tmp
;
tmp
.
str
=
(
const
char
*
)
get_ptr
();
tmp
.
length
=
get_length
(
ptr
);
tmp
.
str
=
(
const
char
*
)
get_ptr
(
ptr_arg
);
tmp
.
length
=
get_length
(
ptr
_arg
);
return
Geometry
::
get_key_image_itMBR
(
tmp
,
buff
,
length
);
}
return
Field_blob
::
get_key_image_itRAW
(
buff
,
length
);
return
Field_blob
::
get_key_image_itRAW
(
ptr_arg
,
buff
,
length
);
}
Binlog_type_info
Field_geom
::
binlog_type_info
()
const
...
...
sql/sql_type_geom.h
View file @
7f9b3ea9
...
...
@@ -412,7 +412,8 @@ class Field_geom :public Field_blob
represented differently, but we need to support it either way.
*/
uint32
key_length
()
const
override
{
return
packlength
;
}
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type_arg
)
override
;
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
const
uchar
*
ptr_arg
,
imagetype
type_arg
)
const
override
;
/**
Non-nullable GEOMETRY types cannot have defaults,
...
...
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