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
d4170f64
Commit
d4170f64
authored
Nov 16, 2016
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: set_field_ptr()
parent
65e53c8b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
50 deletions
+30
-50
sql/ha_partition.cc
sql/ha_partition.cc
+2
-2
sql/sql_partition.cc
sql/sql_partition.cc
+14
-47
sql/sql_partition.h
sql/sql_partition.h
+0
-1
sql/table.cc
sql/table.cc
+12
-0
sql/table.h
sql/table.h
+2
-0
No files found.
sql/ha_partition.cc
View file @
d4170f64
...
...
@@ -7959,7 +7959,7 @@ void ha_partition::append_row_to_str(String &str)
{
Field
**
field_ptr
;
if
(
!
is_rec0
)
set_field_ptr
(
m_part_info
->
full_part_field_array
,
rec
,
table
->
move_fields
(
m_part_info
->
full_part_field_array
,
rec
,
table
->
record
[
0
]);
/* No primary key, use full partition field array. */
for
(
field_ptr
=
m_part_info
->
full_part_field_array
;
...
...
@@ -7973,7 +7973,7 @@ void ha_partition::append_row_to_str(String &str)
field_unpack
(
&
str
,
field
,
rec
,
0
,
false
);
}
if
(
!
is_rec0
)
set_field_ptr
(
m_part_info
->
full_part_field_array
,
table
->
record
[
0
],
table
->
move_fields
(
m_part_info
->
full_part_field_array
,
table
->
record
[
0
],
rec
);
}
}
...
...
sql/sql_partition.cc
View file @
d4170f64
...
...
@@ -293,10 +293,10 @@ int get_parts_for_update(const uchar *old_data, uchar *new_data,
DBUG_ENTER
(
"get_parts_for_update"
);
DBUG_ASSERT
(
new_data
==
rec0
);
// table->record[0]
set_field_ptr
(
part_field_array
,
old_data
,
rec0
);
part_info
->
table
->
move_fields
(
part_field_array
,
old_data
,
rec0
);
error
=
part_info
->
get_partition_id
(
part_info
,
old_part_id
,
&
old_func_value
);
set_field_ptr
(
part_field_array
,
rec0
,
old_data
);
part_info
->
table
->
move_fields
(
part_field_array
,
rec0
,
old_data
);
if
(
unlikely
(
error
))
// Should never happen
{
DBUG_ASSERT
(
0
);
...
...
@@ -321,10 +321,10 @@ int get_parts_for_update(const uchar *old_data, uchar *new_data,
future use. It will be tested by ensuring that the above
condition is false in one test situation before pushing the code.
*/
set_field_ptr
(
part_field_array
,
new_data
,
rec0
);
part_info
->
table
->
move_fields
(
part_field_array
,
new_data
,
rec0
);
error
=
part_info
->
get_partition_id
(
part_info
,
new_part_id
,
new_func_value
);
set_field_ptr
(
part_field_array
,
rec0
,
new_data
);
part_info
->
table
->
move_fields
(
part_field_array
,
rec0
,
new_data
);
if
(
unlikely
(
error
))
{
DBUG_RETURN
(
error
);
...
...
@@ -375,9 +375,9 @@ int get_part_for_delete(const uchar *buf, const uchar *rec0,
else
{
Field
**
part_field_array
=
part_info
->
full_part_field_array
;
set_field_ptr
(
part_field_array
,
buf
,
rec0
);
part_info
->
table
->
move_fields
(
part_field_array
,
buf
,
rec0
);
error
=
part_info
->
get_partition_id
(
part_info
,
part_id
,
&
func_value
);
set_field_ptr
(
part_field_array
,
rec0
,
buf
);
part_info
->
table
->
move_fields
(
part_field_array
,
rec0
,
buf
);
if
(
unlikely
(
error
))
{
DBUG_RETURN
(
error
);
...
...
@@ -3787,9 +3787,9 @@ static int get_sub_part_id_from_key(const TABLE *table,uchar *buf,
else
{
Field
**
part_field_array
=
part_info
->
subpart_field_array
;
set_field_ptr
(
part_field_array
,
buf
,
rec0
);
part_info
->
table
->
move_fields
(
part_field_array
,
buf
,
rec0
);
res
=
part_info
->
get_subpartition_id
(
part_info
,
part_id
);
set_field_ptr
(
part_field_array
,
rec0
,
buf
);
part_info
->
table
->
move_fields
(
part_field_array
,
rec0
,
buf
);
}
DBUG_RETURN
(
res
);
}
...
...
@@ -3833,10 +3833,10 @@ bool get_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info,
else
{
Field
**
part_field_array
=
part_info
->
part_field_array
;
set_field_ptr
(
part_field_array
,
buf
,
rec0
);
part_info
->
table
->
move_fields
(
part_field_array
,
buf
,
rec0
);
result
=
part_info
->
get_part_partition_id
(
part_info
,
part_id
,
&
func_value
);
set_field_ptr
(
part_field_array
,
rec0
,
buf
);
part_info
->
table
->
move_fields
(
part_field_array
,
rec0
,
buf
);
}
DBUG_RETURN
(
result
);
}
...
...
@@ -3882,10 +3882,10 @@ void get_full_part_id_from_key(const TABLE *table, uchar *buf,
else
{
Field
**
part_field_array
=
part_info
->
full_part_field_array
;
set_field_ptr
(
part_field_array
,
buf
,
rec0
);
part_info
->
table
->
move_fields
(
part_field_array
,
buf
,
rec0
);
result
=
part_info
->
get_partition_id
(
part_info
,
&
part_spec
->
start_part
,
&
func_value
);
set_field_ptr
(
part_field_array
,
rec0
,
buf
);
part_info
->
table
->
move_fields
(
part_field_array
,
rec0
,
buf
);
}
part_spec
->
end_part
=
part_spec
->
start_part
;
if
(
unlikely
(
result
))
...
...
@@ -3935,7 +3935,7 @@ bool verify_data_with_partition(TABLE *table, TABLE *part_table,
bitmap_union
(
table
->
read_set
,
&
part_info
->
full_part_field_set
);
old_rec
=
part_table
->
record
[
0
];
part_table
->
record
[
0
]
=
table
->
record
[
0
];
set_field_ptr
(
part_info
->
full_part_field_array
,
table
->
record
[
0
],
old_rec
);
part_info
->
table
->
move_fields
(
part_info
->
full_part_field_array
,
table
->
record
[
0
],
old_rec
);
if
((
error
=
file
->
ha_rnd_init
(
TRUE
)))
{
file
->
print_error
(
error
,
MYF
(
0
));
...
...
@@ -3970,7 +3970,7 @@ bool verify_data_with_partition(TABLE *table, TABLE *part_table,
}
while
(
TRUE
);
(
void
)
file
->
ha_rnd_end
();
err:
set_field_ptr
(
part_info
->
full_part_field_array
,
old_rec
,
part_info
->
table
->
move_fields
(
part_info
->
full_part_field_array
,
old_rec
,
table
->
record
[
0
]);
part_table
->
record
[
0
]
=
old_rec
;
if
(
error
)
...
...
@@ -7211,39 +7211,6 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
}
#endif
/*
Prepare for calling val_int on partition function by setting fields to
point to the record where the values of the PF-fields are stored.
SYNOPSIS
set_field_ptr()
ptr Array of fields to change ptr
new_buf New record pointer
old_buf Old record pointer
DESCRIPTION
Set ptr in field objects of field array to refer to new_buf record
instead of previously old_buf. Used before calling val_int and after
it is used to restore pointers to table->record[0].
This routine is placed outside of partition code since it can be useful
also for other programs.
*/
void
set_field_ptr
(
Field
**
ptr
,
const
uchar
*
new_buf
,
const
uchar
*
old_buf
)
{
my_ptrdiff_t
diff
=
(
new_buf
-
old_buf
);
DBUG_ENTER
(
"set_field_ptr"
);
do
{
(
*
ptr
)
->
move_field_offset
(
diff
);
}
while
(
*
(
++
ptr
));
DBUG_VOID_RETURN
;
}
/*
Prepare for calling val_int on partition function by setting fields to
point to the record where the values of the PF-fields are stored.
...
...
sql/sql_partition.h
View file @
d4170f64
...
...
@@ -288,7 +288,6 @@ void create_subpartition_name(char *out, const char *in1,
const
char
*
in2
,
const
char
*
in3
,
uint
name_variant
);
void
set_field_ptr
(
Field
**
ptr
,
const
uchar
*
new_buf
,
const
uchar
*
old_buf
);
void
set_key_field_ptr
(
KEY
*
key_info
,
const
uchar
*
new_buf
,
const
uchar
*
old_buf
);
...
...
sql/table.cc
View file @
d4170f64
...
...
@@ -6633,6 +6633,18 @@ void TABLE::mark_default_fields_for_write(bool is_insert)
DBUG_VOID_RETURN
;
}
void
TABLE
::
move_fields
(
Field
**
ptr
,
const
uchar
*
to
,
const
uchar
*
from
)
{
my_ptrdiff_t
diff
=
to
-
from
;
if
(
diff
)
{
do
{
(
*
ptr
)
->
move_field_offset
(
diff
);
}
while
(
*
(
++
ptr
));
}
}
/**
@brief
...
...
sql/table.h
View file @
d4170f64
...
...
@@ -1419,6 +1419,8 @@ struct TABLE
my_ptrdiff_t
default_values_offset
()
const
{
return
(
my_ptrdiff_t
)
(
s
->
default_values
-
record
[
0
]);
}
void
move_fields
(
Field
**
ptr
,
const
uchar
*
to
,
const
uchar
*
from
);
uint
actual_n_key_parts
(
KEY
*
keyinfo
);
ulong
actual_key_flags
(
KEY
*
keyinfo
);
int
update_virtual_fields
(
enum_vcol_update_mode
update_mode
);
...
...
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