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
9bcfd27b
Commit
9bcfd27b
authored
Nov 28, 2015
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: remove dead (half-merged) code from partition_info.*
parent
5b716bc2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
378 deletions
+1
-378
sql/partition_info.cc
sql/partition_info.cc
+0
-299
sql/partition_info.h
sql/partition_info.h
+1
-50
sql/sql_trigger.cc
sql/sql_trigger.cc
+0
-29
No files found.
sql/partition_info.cc
View file @
9bcfd27b
...
...
@@ -253,7 +253,6 @@ bool partition_info::set_partition_bitmaps(TABLE_LIST *table_list)
DBUG_ASSERT
(
bitmaps_are_initialized
);
DBUG_ASSERT
(
table
);
is_pruning_completed
=
false
;
if
(
!
bitmaps_are_initialized
)
DBUG_RETURN
(
TRUE
);
...
...
@@ -280,239 +279,6 @@ bool partition_info::set_partition_bitmaps(TABLE_LIST *table_list)
}
/**
Checks if possible to do prune partitions on insert.
@param thd Thread context
@param duplic How to handle duplicates
@param update In case of ON DUPLICATE UPDATE, default function fields
@param update_fields In case of ON DUPLICATE UPDATE, which fields to update
@param fields Listed fields
@param empty_values True if values is empty (only defaults)
@param[out] prune_needs_default_values Set on return if copying of default
values is needed
@param[out] can_prune_partitions Enum showing if possible to prune
@param[inout] used_partitions If possible to prune the bitmap
is initialized and cleared
@return Operation status
@retval false Success
@retval true Failure
*/
bool
partition_info
::
can_prune_insert
(
THD
*
thd
,
enum_duplicates
duplic
,
COPY_INFO
&
update
,
List
<
Item
>
&
update_fields
,
List
<
Item
>
&
fields
,
bool
empty_values
,
enum_can_prune
*
can_prune_partitions
,
bool
*
prune_needs_default_values
,
MY_BITMAP
*
used_partitions
)
{
uint32
*
bitmap_buf
;
uint
bitmap_bytes
;
uint
num_partitions
=
0
;
*
can_prune_partitions
=
PRUNE_NO
;
DBUG_ASSERT
(
bitmaps_are_initialized
);
DBUG_ENTER
(
"partition_info::can_prune_insert"
);
if
(
table
->
s
->
db_type
()
->
partition_flags
()
&
HA_USE_AUTO_PARTITION
)
DBUG_RETURN
(
false
);
/*
If under LOCK TABLES pruning will skip start_stmt instead of external_lock
for unused partitions.
Cannot prune if there are BEFORE INSERT triggers that changes any
partitioning column, since they may change the row to be in another
partition.
*/
if
(
is_fields_updated_in_triggers
(
TRG_EVENT_INSERT
,
TRG_ACTION_BEFORE
))
DBUG_RETURN
(
false
);
if
(
table
->
found_next_number_field
)
{
/*
If the field is used in the partitioning expression, we cannot prune.
TODO: If all rows have not null values and
is not 0 (with NO_AUTO_VALUE_ON_ZERO sql_mode), then pruning is possible!
*/
if
(
bitmap_is_set
(
&
full_part_field_set
,
table
->
found_next_number_field
->
field_index
))
DBUG_RETURN
(
false
);
}
/*
If updating a field in the partitioning expression, we cannot prune.
Note: TIMESTAMP_AUTO_SET_ON_INSERT is handled by converting Item_null
to the start time of the statement. Which will be the same as in
write_row(). So pruning of TIMESTAMP DEFAULT CURRENT_TIME will work.
But TIMESTAMP_AUTO_SET_ON_UPDATE cannot be pruned if the timestamp
column is a part of any part/subpart expression.
*/
if
(
duplic
==
DUP_UPDATE
)
{
/*
TODO: add check for static update values, which can be pruned.
*/
if
(
is_field_in_part_expr
(
update_fields
))
DBUG_RETURN
(
false
);
/*
Cannot prune if there are BEFORE UPDATE triggers that changes any
partitioning column, since they may change the row to be in another
partition.
*/
if
(
is_fields_updated_in_triggers
(
TRG_EVENT_UPDATE
,
TRG_ACTION_BEFORE
))
DBUG_RETURN
(
false
);
}
/*
If not all partitioning fields are given,
we also must set all non given partitioning fields
to get correct defaults.
TODO: If any gain, we could enhance this by only copy the needed default
fields by
1) check which fields needs to be set.
2) only copy those fields from the default record.
*/
*
prune_needs_default_values
=
false
;
if
(
fields
.
elements
)
{
if
(
!
is_full_part_expr_in_fields
(
fields
))
*
prune_needs_default_values
=
true
;
}
else
if
(
empty_values
)
{
*
prune_needs_default_values
=
true
;
// like 'INSERT INTO t () VALUES ()'
}
else
{
/*
In case of INSERT INTO t VALUES (...) we must get values for
all fields in table from VALUES (...) part, so no defaults
are needed.
*/
}
/* Pruning possible, have to initialize the used_partitions bitmap. */
num_partitions
=
lock_partitions
.
n_bits
;
bitmap_bytes
=
bitmap_buffer_size
(
num_partitions
);
if
(
!
(
bitmap_buf
=
(
uint32
*
)
thd
->
alloc
(
bitmap_bytes
)))
{
mem_alloc_error
(
bitmap_bytes
);
DBUG_RETURN
(
true
);
}
/* Also clears all bits. */
if
(
my_bitmap_init
(
used_partitions
,
bitmap_buf
,
num_partitions
,
false
))
{
/* purecov: begin deadcode */
/* Cannot happen, due to pre-alloc. */
mem_alloc_error
(
bitmap_bytes
);
DBUG_RETURN
(
true
);
/* purecov: end */
}
/*
If no partitioning field in set (e.g. defaults) check pruning only once.
*/
if
(
fields
.
elements
&&
!
is_field_in_part_expr
(
fields
))
*
can_prune_partitions
=
PRUNE_DEFAULTS
;
else
*
can_prune_partitions
=
PRUNE_YES
;
DBUG_RETURN
(
false
);
}
/**
Mark the partition, the record belongs to, as used.
@param fields Fields to set
@param values Values to use
@param info COPY_INFO used for default values handling
@param copy_default_values True if we should copy default values
@param used_partitions Bitmap to set
@returns Operational status
@retval false Success
@retval true Failure
*/
bool
partition_info
::
set_used_partition
(
List
<
Item
>
&
fields
,
List
<
Item
>
&
values
,
COPY_INFO
&
info
,
bool
copy_default_values
,
MY_BITMAP
*
used_partitions
)
{
THD
*
thd
=
table
->
in_use
;
uint32
part_id
;
longlong
func_value
;
Dummy_error_handler
error_handler
;
bool
ret
=
true
;
DBUG_ENTER
(
"set_partition"
);
DBUG_ASSERT
(
thd
);
/* Only allow checking of constant values */
List_iterator_fast
<
Item
>
v
(
values
);
Item
*
item
;
thd
->
push_internal_handler
(
&
error_handler
);
while
((
item
=
v
++
))
{
if
(
!
item
->
const_item
())
goto
err
;
}
if
(
copy_default_values
)
restore_record
(
table
,
s
->
default_values
);
if
(
fields
.
elements
||
!
values
.
elements
)
{
if
(
fill_record
(
thd
,
table
,
fields
,
values
,
false
,
!
copy_default_values
))
goto
err
;
}
else
{
/* All fields has a value */
if
(
fill_record
(
thd
,
table
,
table
->
field
,
values
,
false
,
false
))
goto
err
;
}
DBUG_ASSERT
(
!
table
->
auto_increment_field_not_null
);
/*
Evaluate DEFAULT functions like CURRENT_TIMESTAMP.
TODO: avoid setting non partitioning fields default value, to avoid
overhead. Not yet done, since mostly only one DEFAULT function per
table, or at least very few such columns.
*/
// if (info.function_defaults_apply_on_columns(&full_part_field_set))
// info.set_function_defaults(table);
{
/*
This function is used in INSERT; 'values' are supplied by user,
or are default values, not values read from a table, so read_set is
irrelevant.
*/
my_bitmap_map
*
old_map
=
dbug_tmp_use_all_columns
(
table
,
table
->
read_set
);
const
int
rc
=
get_partition_id
(
this
,
&
part_id
,
&
func_value
);
dbug_tmp_restore_column_map
(
table
->
read_set
,
old_map
);
if
(
rc
)
goto
err
;
}
DBUG_PRINT
(
"info"
,
(
"Insert into partition %u"
,
part_id
));
bitmap_set_bit
(
used_partitions
,
part_id
);
ret
=
false
;
err:
thd
->
pop_internal_handler
();
DBUG_RETURN
(
ret
);
}
/*
Create a memory area where default partition names are stored and fill it
up with the names.
...
...
@@ -2167,71 +1933,6 @@ void partition_info::report_part_expr_error(bool use_subpart_expr)
}
/**
Check if fields are in the partitioning expression.
@param fields List of Items (fields)
@return True if any field in the fields list is used by a partitioning expr.
@retval true At least one field in the field list is found.
@retval false No field is within any partitioning expression.
*/
bool
partition_info
::
is_field_in_part_expr
(
List
<
Item
>
&
fields
)
{
List_iterator
<
Item
>
it
(
fields
);
Item
*
item
;
Item_field
*
field
;
DBUG_ENTER
(
"is_fields_in_part_expr"
);
while
((
item
=
it
++
))
{
field
=
item
->
field_for_view_update
();
DBUG_ASSERT
(
field
->
field
->
table
==
table
);
if
(
bitmap_is_set
(
&
full_part_field_set
,
field
->
field
->
field_index
))
DBUG_RETURN
(
true
);
}
DBUG_RETURN
(
false
);
}
/**
Check if all partitioning fields are included.
*/
bool
partition_info
::
is_full_part_expr_in_fields
(
List
<
Item
>
&
fields
)
{
Field
**
part_field
=
full_part_field_array
;
DBUG_ASSERT
(
*
part_field
);
DBUG_ENTER
(
"is_full_part_expr_in_fields"
);
/*
It is very seldom many fields in full_part_field_array, so it is OK
to loop over all of them instead of creating a bitmap fields argument
to compare with.
*/
do
{
List_iterator
<
Item
>
it
(
fields
);
Item
*
item
;
Item_field
*
field
;
bool
found
=
false
;
while
((
item
=
it
++
))
{
field
=
item
->
field_for_view_update
();
DBUG_ASSERT
(
field
->
field
->
table
==
table
);
if
(
*
part_field
==
field
->
field
)
{
found
=
true
;
break
;
}
}
if
(
!
found
)
DBUG_RETURN
(
false
);
}
while
(
*
(
++
part_field
));
DBUG_RETURN
(
true
);
}
/*
Create a new column value in current list with maxvalue
Called from parser
...
...
sql/partition_info.h
View file @
9bcfd27b
...
...
@@ -242,15 +242,6 @@ class partition_info : public Sql_alloc
bool
is_auto_partitioned
;
bool
has_null_value
;
bool
column_list
;
// COLUMNS PARTITIONING, 5.5+
/**
True if pruning has been completed and can not be pruned any further,
even if there are subqueries or stored programs in the condition.
Some times it is needed to run prune_partitions() a second time to prune
read partitions after tables are locked, when subquery and
stored functions might have been evaluated.
*/
bool
is_pruning_completed
;
partition_info
()
:
get_partition_id
(
NULL
),
get_part_partition_id
(
NULL
),
...
...
@@ -284,7 +275,7 @@ class partition_info : public Sql_alloc
list_of_part_fields
(
FALSE
),
list_of_subpart_fields
(
FALSE
),
linear_hash_ind
(
FALSE
),
fixed
(
FALSE
),
is_auto_partitioned
(
FALSE
),
has_null_value
(
FALSE
),
column_list
(
FALSE
)
,
is_pruning_completed
(
false
)
has_null_value
(
FALSE
),
column_list
(
FALSE
)
{
all_fields_in_PF
.
clear_all
();
all_fields_in_PPF
.
clear_all
();
...
...
@@ -348,46 +339,8 @@ class partition_info : public Sql_alloc
char
*
file_name
,
uint32
*
part_id
);
void
report_part_expr_error
(
bool
use_subpart_expr
);
bool
set_used_partition
(
List
<
Item
>
&
fields
,
List
<
Item
>
&
values
,
COPY_INFO
&
info
,
bool
copy_default_values
,
MY_BITMAP
*
used_partitions
);
/**
PRUNE_NO - Unable to prune.
PRUNE_DEFAULTS - Partitioning field is only set to
DEFAULT values, only need to check
pruning for one row where the DEFAULTS
values are set.
PRUNE_YES - Pruning is possible, calculate the used partition set
by evaluate the partition_id on row by row basis.
*/
enum
enum_can_prune
{
PRUNE_NO
=
0
,
PRUNE_DEFAULTS
,
PRUNE_YES
};
bool
can_prune_insert
(
THD
*
thd
,
enum_duplicates
duplic
,
COPY_INFO
&
update
,
List
<
Item
>
&
update_fields
,
List
<
Item
>
&
fields
,
bool
empty_values
,
enum_can_prune
*
can_prune_partitions
,
bool
*
prune_needs_default_values
,
MY_BITMAP
*
used_partitions
);
bool
has_same_partitioning
(
partition_info
*
new_part_info
);
private:
bool
is_fields_updated_in_triggers
(
trg_event_type
event_type
,
trg_action_time_type
action_time_type
)
{
if
(
table
->
triggers
)
{
Trigger
*
t
;
for
(
t
=
table
->
triggers
->
get_trigger
(
event_type
,
action_time_type
);
t
;
t
=
t
->
next
)
if
(
t
->
is_fields_updated_in_trigger
(
&
full_part_field_set
))
return
true
;
}
return
false
;
}
static
int
list_part_cmp
(
const
void
*
a
,
const
void
*
b
);
bool
set_up_default_partitions
(
THD
*
thd
,
handler
*
file
,
HA_CREATE_INFO
*
info
,
uint
start_no
);
...
...
@@ -399,8 +352,6 @@ class partition_info : public Sql_alloc
const
char
*
part_name
);
bool
prune_partition_bitmaps
(
TABLE_LIST
*
table_list
);
bool
add_named_partition
(
const
char
*
part_name
,
uint
length
);
bool
is_field_in_part_expr
(
List
<
Item
>
&
fields
);
bool
is_full_part_expr_in_fields
(
List
<
Item
>
&
fields
);
public:
bool
has_unique_name
(
partition_element
*
element
);
};
...
...
sql/sql_trigger.cc
View file @
9bcfd27b
...
...
@@ -2249,35 +2249,6 @@ add_tables_and_routines_for_triggers(THD *thd,
}
/**
Check if any of the marked fields are used in the trigger.
@param used_fields Bitmap over fields to check
@param event_type Type of event triggers for which we are going to inspect
@param action_time Type of trigger action time we are going to inspect
*/
bool
Trigger
::
is_fields_updated_in_trigger
(
MY_BITMAP
*
used_fields
)
{
Item_trigger_field
*
trg_field
;
sp_head
*
sp
=
body
;
DBUG_ASSERT
(
used_fields
->
n_bits
==
base
->
trigger_table
->
s
->
fields
);
for
(
trg_field
=
sp
->
m_trg_table_fields
.
first
;
trg_field
;
trg_field
=
trg_field
->
next_trg_field
)
{
/* We cannot check fields which does not present in table. */
if
(
trg_field
->
field_idx
!=
(
uint
)
-
1
)
{
if
(
bitmap_is_set
(
used_fields
,
trg_field
->
field_idx
)
&&
trg_field
->
get_settable_routine_parameter
())
return
true
;
}
}
return
false
;
}
/**
Mark fields of subject table which we read/set in its triggers
as such.
...
...
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