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
d65fdb31
Commit
d65fdb31
authored
Dec 13, 2009
by
Alexey Kopytov
Browse files
Options
Browse Files
Download
Plain Diff
Automerge
parents
8969530c
c08e6c88
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
743 additions
and
25 deletions
+743
-25
mysql-test/r/partition_bug18198.result
mysql-test/r/partition_bug18198.result
+1
-1
mysql-test/r/partition_error.result
mysql-test/r/partition_error.result
+301
-9
mysql-test/t/partition_bug18198.test
mysql-test/t/partition_bug18198.test
+1
-1
mysql-test/t/partition_error.test
mysql-test/t/partition_error.test
+362
-2
sql/item.h
sql/item.h
+9
-0
sql/item_func.h
sql/item_func.h
+23
-0
sql/item_timefunc.h
sql/item_timefunc.h
+10
-0
sql/share/errmsg.txt
sql/share/errmsg.txt
+2
-2
sql/sql_partition.cc
sql/sql_partition.cc
+33
-6
sql/sql_partition.h
sql/sql_partition.h
+0
-3
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
mysql-test/r/partition_bug18198.result
View file @
d65fdb31
...
...
@@ -126,7 +126,7 @@ ERROR HY000: This partition function is not allowed
create table t1 (col1 date)
partition by range(unix_timestamp(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000:
This partition function is
not allowed
ERROR HY000:
Constant, random or timezone-dependent expressions in (sub)partitioning function are
not allowed
create table t1 (col1 datetime)
partition by range(week(col1))
(partition p0 values less than (10), partition p1 values less than (30));
...
...
mysql-test/r/partition_error.result
View file @
d65fdb31
This diff is collapsed.
Click to expand it.
mysql-test/t/partition_bug18198.test
View file @
d65fdb31
...
...
@@ -158,7 +158,7 @@ create table t1 (col1 datetime)
partition
by
range
(
timestampdiff
(
day
,
5
,
col1
))
(
partition
p0
values
less
than
(
10
),
partition
p1
values
less
than
(
30
));
--
error
ER_
PARTITION_FUNCTION_IS_NOT_ALLOWED
--
error
ER_
WRONG_EXPR_IN_PARTITION_FUNC_ERROR
create
table
t1
(
col1
date
)
partition
by
range
(
unix_timestamp
(
col1
))
(
partition
p0
values
less
than
(
10
),
partition
p1
values
less
than
(
30
));
...
...
mysql-test/t/partition_error.test
View file @
d65fdb31
This diff is collapsed.
Click to expand it.
sql/item.h
View file @
d65fdb31
...
...
@@ -957,6 +957,15 @@ class Item {
virtual
Item
*
equal_fields_propagator
(
uchar
*
arg
)
{
return
this
;
}
virtual
bool
set_no_const_sub
(
uchar
*
arg
)
{
return
FALSE
;
}
virtual
Item
*
replace_equal_field
(
uchar
*
arg
)
{
return
this
;
}
/*
Check if an expression value depends on the current timezone. Used by
partitioning code to reject timezone-dependent expressions in a
(sub)partitioning function.
*/
virtual
bool
is_timezone_dependent_processor
(
uchar
*
bool_arg
)
{
return
FALSE
;
}
/*
For SP local variable returns pointer to Item representing its
...
...
sql/item_func.h
View file @
d65fdb31
...
...
@@ -189,6 +189,29 @@ class Item_func :public Item_result_field
null_value
=
1
;
return
0.0
;
}
bool
has_timestamp_args
()
{
DBUG_ASSERT
(
fixed
==
TRUE
);
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
if
(
args
[
i
]
->
type
()
==
Item
::
FIELD_ITEM
&&
args
[
i
]
->
field_type
()
==
MYSQL_TYPE_TIMESTAMP
)
return
TRUE
;
}
return
FALSE
;
}
/*
We assume the result of any function that has a TIMESTAMP argument to be
timezone-dependent, since a TIMESTAMP value in both numeric and string
contexts is interpreted according to the current timezone.
The only exception is UNIX_TIMESTAMP() which returns the internal
representation of a TIMESTAMP argument verbatim, and thus does not depend on
the timezone.
*/
virtual
bool
is_timezone_dependent_processor
(
uchar
*
bool_arg
)
{
return
has_timestamp_args
();
}
};
...
...
sql/item_timefunc.h
View file @
d65fdb31
...
...
@@ -305,6 +305,16 @@ class Item_func_unix_timestamp :public Item_int_func
Item_func_unix_timestamp
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"unix_timestamp"
;
}
bool
check_partition_func_processor
(
uchar
*
int_arg
)
{
return
FALSE
;}
/*
UNIX_TIMESTAMP() depends on the current timezone
(and thus may not be used as a partitioning function)
when its argument is NOT of the TIMESTAMP type.
*/
bool
is_timezone_dependent_processor
(
uchar
*
int_arg
)
{
return
!
has_timestamp_args
();
}
void
fix_length_and_dec
()
{
decimals
=
0
;
...
...
sql/share/errmsg.txt
View file @
d65fdb31
...
...
@@ -5696,8 +5696,8 @@ ER_PARTITION_WRONG_NO_SUBPART_ERROR
eng "Wrong number of subpartitions defined, mismatch with previous setting"
ger "Falsche Anzahl von Unterpartitionen definiert, stimmt nicht mit vorherigen Einstellungen berein"
swe "Antal subpartitioner definierade och antal subpartitioner r inte lika"
ER_
CONST
_EXPR_IN_PARTITION_FUNC_ERROR
eng "Constant
/Random expression in (sub)partitioning function is
not allowed"
ER_
WRONG
_EXPR_IN_PARTITION_FUNC_ERROR
eng "Constant
, random or timezone-dependent expressions in (sub)partitioning function are
not allowed"
ger "Konstante oder Random-Ausdrcke in (Unter-)Partitionsfunktionen sind nicht erlaubt"
swe "Konstanta uttryck eller slumpmssiga uttryck r inte tilltna (sub)partitioneringsfunktioner"
ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR
...
...
sql/sql_partition.cc
View file @
d65fdb31
...
...
@@ -870,6 +870,8 @@ int check_signed_flag(partition_info *part_info)
part_info Reference to partitioning data structure
is_sub_part Is the table subpartitioned as well
is_field_to_be_setup Flag if we are to set-up field arrays
is_create_table_ind Indicator of whether openfrm was called as part of
CREATE or ALTER TABLE
RETURN VALUE
TRUE An error occurred, something was wrong with the
...
...
@@ -892,8 +894,9 @@ int check_signed_flag(partition_info *part_info)
on the field object.
*/
bool
fix_fields_part_func
(
THD
*
thd
,
Item
*
func_expr
,
TABLE
*
table
,
bool
is_sub_part
,
bool
is_field_to_be_setup
)
static
bool
fix_fields_part_func
(
THD
*
thd
,
Item
*
func_expr
,
TABLE
*
table
,
bool
is_sub_part
,
bool
is_field_to_be_setup
,
bool
is_create_table_ind
)
{
partition_info
*
part_info
=
table
->
part_info
;
uint
dir_length
,
home_dir_length
;
...
...
@@ -1005,10 +1008,31 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
thd
->
where
=
save_where
;
if
(
unlikely
(
func_expr
->
const_item
()))
{
my_error
(
ER_
CONST
_EXPR_IN_PARTITION_FUNC_ERROR
,
MYF
(
0
));
my_error
(
ER_
WRONG
_EXPR_IN_PARTITION_FUNC_ERROR
,
MYF
(
0
));
clear_field_flag
(
table
);
goto
end
;
}
/*
We don't allow creating partitions with timezone-dependent expressions as
a (sub)partitioning function, but we want to allow such expressions when
opening existing tables for easier maintenance. This exception should be
deprecated at some point in future so that we always throw an error.
*/
if
(
func_expr
->
walk
(
&
Item
::
is_timezone_dependent_processor
,
0
,
NULL
))
{
if
(
is_create_table_ind
)
{
my_error
(
ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
,
MYF
(
0
));
goto
end
;
}
else
push_warning
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
,
ER
(
ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
));
}
if
((
!
is_sub_part
)
&&
(
error
=
check_signed_flag
(
part_info
)))
goto
end
;
result
=
FALSE
;
...
...
@@ -1616,7 +1640,8 @@ bool fix_partition_func(THD *thd, TABLE *table,
else
{
if
(
unlikely
(
fix_fields_part_func
(
thd
,
part_info
->
subpart_expr
,
table
,
TRUE
,
TRUE
)))
table
,
TRUE
,
TRUE
,
is_create_table_ind
)))
goto
end
;
if
(
unlikely
(
part_info
->
subpart_expr
->
result_type
()
!=
INT_RESULT
))
{
...
...
@@ -1644,7 +1669,8 @@ bool fix_partition_func(THD *thd, TABLE *table,
else
{
if
(
unlikely
(
fix_fields_part_func
(
thd
,
part_info
->
part_expr
,
table
,
FALSE
,
TRUE
)))
table
,
FALSE
,
TRUE
,
is_create_table_ind
)))
goto
end
;
if
(
unlikely
(
part_info
->
part_expr
->
result_type
()
!=
INT_RESULT
))
{
...
...
@@ -1658,7 +1684,8 @@ bool fix_partition_func(THD *thd, TABLE *table,
{
const
char
*
error_str
;
if
(
unlikely
(
fix_fields_part_func
(
thd
,
part_info
->
part_expr
,
table
,
FALSE
,
TRUE
)))
table
,
FALSE
,
TRUE
,
is_create_table_ind
)))
goto
end
;
if
(
part_info
->
part_type
==
RANGE_PARTITION
)
{
...
...
sql/sql_partition.h
View file @
d65fdb31
...
...
@@ -91,9 +91,6 @@ uint32 get_list_array_idx_for_endpoint(partition_info *part_info,
uint32
get_partition_id_range_for_endpoint
(
partition_info
*
part_info
,
bool
left_endpoint
,
bool
include_endpoint
);
bool
fix_fields_part_func
(
THD
*
thd
,
Item
*
func_expr
,
TABLE
*
table
,
bool
is_sub_part
,
bool
is_field_to_be_setup
);
bool
check_part_func_fields
(
Field
**
ptr
,
bool
ok_with_charsets
);
bool
field_is_partition_charset
(
Field
*
field
);
...
...
sql/sql_yacc.yy
View file @
d65fdb31
...
...
@@ -4111,7 +4111,7 @@ part_func_expr:
lex->safe_to_cache_query= 1;
if (not_corr_func)
{
my_parse_error(ER(ER_
CONST
_EXPR_IN_PARTITION_FUNC_ERROR));
my_parse_error(ER(ER_
WRONG
_EXPR_IN_PARTITION_FUNC_ERROR));
MYSQL_YYABORT;
}
$$=$1;
...
...
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