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
e08a37bc
Commit
e08a37bc
authored
Jul 22, 2005
by
pappa@c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG #12097 patch
parent
fdb645d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
41 deletions
+40
-41
sql/handler.h
sql/handler.h
+4
-4
sql/sql_partition.cc
sql/sql_partition.cc
+14
-32
sql/sql_yacc.yy
sql/sql_yacc.yy
+22
-5
No files found.
sql/handler.h
View file @
e08a37bc
...
...
@@ -402,12 +402,12 @@ class Item;
class
partition_element
:
public
Sql_alloc
{
public:
List
<
partition_element
>
subpartitions
;
List
<
Item
>
list_expr
_list
;
List
<
longlong
>
list_val
_list
;
ulonglong
part_max_rows
;
ulonglong
part_min_rows
;
char
*
partition_name
;
char
*
tablespace_name
;
Item
*
range_expr
;
longlong
range_value
;
char
*
part_comment
;
char
*
data_file_name
;
char
*
index_file_name
;
...
...
@@ -416,12 +416,12 @@ public:
partition_element
()
:
part_max_rows
(
0
),
part_min_rows
(
0
),
partition_name
(
NULL
),
tablespace_name
(
NULL
),
range_
expr
(
NULL
),
part_comment
(
NULL
),
tablespace_name
(
NULL
),
range_
value
(
0
),
part_comment
(
NULL
),
data_file_name
(
NULL
),
index_file_name
(
NULL
),
engine_type
(
DB_TYPE_UNKNOWN
),
nodegroup_id
(
UNDEF_NODEGROUP
)
{
subpartitions
.
empty
();
list_
expr
_list
.
empty
();
list_
val
_list
.
empty
();
}
~
partition_element
()
{}
};
...
...
sql/sql_partition.cc
View file @
e08a37bc
...
...
@@ -250,16 +250,7 @@ static bool check_range_constants(partition_info *part_info)
{
part_def
=
it
++
;
if
((
i
!=
(
no_parts
-
1
))
||
!
part_info
->
defined_max_value
)
{
if
(
likely
(
part_def
->
range_expr
->
result_type
()
==
INT_RESULT
))
part_range_value_int
=
part_def
->
range_expr
->
val_int
();
else
{
my_error
(
ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
,
MYF
(
0
),
"LESS THAN"
);
goto
end
;
}
}
part_range_value_int
=
part_def
->
range_value
;
else
part_range_value_int
=
LONGLONG_MAX
;
if
(
likely
(
current_largest_int
<
part_range_value_int
))
...
...
@@ -327,7 +318,7 @@ static int list_part_cmp(const void* a, const void* b)
static
bool
check_list_constants
(
partition_info
*
part_info
)
{
uint
i
,
no_list_values
=
0
,
no_parts
,
list_index
=
0
;
Item
*
list_expr
;
longlong
*
list_value
;
bool
not_first
,
result
=
TRUE
;
longlong
curr_value
,
prev_value
;
partition_element
*
part_def
;
...
...
@@ -342,8 +333,7 @@ static bool check_list_constants(partition_info *part_info)
We use this number to allocate a properly sized array of structs
to keep the partition id and the value to use in that partition.
In the second traversal we check that all Item trees are of the
same type (INT_RESULT) and assign them values in the struct array.
In the second traversal we assign them values in the struct array.
Finally we sort the array of structs in order of values to enable
a quick binary search for the proper value to discover the
...
...
@@ -357,7 +347,7 @@ static bool check_list_constants(partition_info *part_info)
do
{
part_def
=
list_func_it
++
;
List_iterator
<
Item
>
list_val_it1
(
part_def
->
list_expr
_list
);
List_iterator
<
longlong
>
list_val_it1
(
part_def
->
list_val
_list
);
while
(
list_val_it1
++
)
no_list_values
++
;
}
while
(
++
i
<
no_parts
);
...
...
@@ -375,19 +365,11 @@ static bool check_list_constants(partition_info *part_info)
do
{
part_def
=
list_func_it
++
;
List_iterator
<
Item
>
list_val_it2
(
part_def
->
list_expr
_list
);
while
((
list_
expr
=
list_val_it2
++
))
List_iterator
<
longlong
>
list_val_it2
(
part_def
->
list_val
_list
);
while
((
list_
value
=
list_val_it2
++
))
{
if
(
likely
(
list_expr
->
result_type
()
==
INT_RESULT
))
{
part_info
->
list_array
[
list_index
].
list_value
=
list_expr
->
val_int
();
part_info
->
list_array
[
list_index
++
].
partition_id
=
i
;
}
else
{
my_error
(
ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
,
MYF
(
0
),
"IN"
);
goto
end
;
}
part_info
->
list_array
[
list_index
].
list_value
=
*
list_value
;
part_info
->
list_array
[
list_index
++
].
partition_id
=
i
;
}
}
while
(
++
i
<
no_parts
);
...
...
@@ -1820,10 +1802,10 @@ static int add_partition_values(File fptr, partition_info *part_info,
if
(
part_info
->
part_type
==
RANGE_PARTITION
)
{
err
+=
add_string
(
fptr
,
"VALUES LESS THAN "
);
if
(
p_elem
->
range_
expr
)
if
(
p_elem
->
range_
value
!=
LONGLONG_MAX
)
{
err
+=
add_begin_parenthesis
(
fptr
);
err
+=
add_int
(
fptr
,
p_elem
->
range_expr
->
val_int
()
);
err
+=
add_int
(
fptr
,
p_elem
->
range_value
);
err
+=
add_end_parenthesis
(
fptr
);
}
else
...
...
@@ -1832,15 +1814,15 @@ static int add_partition_values(File fptr, partition_info *part_info,
else
if
(
part_info
->
part_type
==
LIST_PARTITION
)
{
uint
i
;
List_iterator
<
Item
>
list_expr_it
(
p_elem
->
list_expr
_list
);
List_iterator
<
longlong
>
list_val_it
(
p_elem
->
list_val
_list
);
err
+=
add_string
(
fptr
,
"VALUES IN "
);
uint
no_items
=
p_elem
->
list_
expr
_list
.
elements
;
uint
no_items
=
p_elem
->
list_
val
_list
.
elements
;
err
+=
add_begin_parenthesis
(
fptr
);
i
=
0
;
do
{
Item
*
list_expr
=
list_expr
_it
++
;
err
+=
add_int
(
fptr
,
list_expr
->
val_int
()
);
longlong
*
list_value
=
list_val
_it
++
;
err
+=
add_int
(
fptr
,
*
list_value
);
if
(
i
!=
(
no_items
-
1
))
err
+=
add_comma
(
fptr
);
}
while
(
++
i
<
no_items
);
...
...
sql/sql_yacc.yy
View file @
e08a37bc
...
...
@@ -73,6 +73,7 @@ inline Item *is_truth_value(Item *A, bool v1, bool v2)
int num;
ulong ulong_num;
ulonglong ulonglong_number;
longlong longlong_number;
LEX_STRING lex_str;
LEX_STRING *lex_str_ptr;
LEX_SYMBOL symbol;
...
...
@@ -716,6 +717,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <ulonglong_number>
ulonglong_num
%type <longlong_number>
part_bit_expr
%type <lock_type>
replace_lock_option opt_low_priority insert_lock_option load_data_lock
...
...
@@ -732,7 +736,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
sp_opt_default
simple_ident_nospvar simple_ident_q
field_or_var limit_option
part_
bit_expr part_
func_expr
part_func_expr
%type <item_num>
NUM_literal
...
...
@@ -2873,7 +2877,7 @@ part_func_max:
part_range_func:
'(' part_bit_expr ')'
{
Lex->part_info->curr_part_elem->range_
expr
= $2;
Lex->part_info->curr_part_elem->range_
value
= $2;
};
part_list_func:
...
...
@@ -2883,7 +2887,14 @@ part_list_func:
part_list_item:
part_bit_expr
{
Lex->part_info->curr_part_elem->list_expr_list.push_back($1);
longlong *value_ptr;
if ((value_ptr= (longlong*)sql_alloc(sizeof(longlong))))
{
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(longlong));
YYABORT;
}
*value_ptr= $1;
Lex->part_info->curr_part_elem->list_val_list.push_back(value_ptr);
};
part_bit_expr:
...
...
@@ -2892,6 +2903,7 @@ part_bit_expr:
Item *part_expr= $1;
bool not_corr_func;
LEX *lex= Lex;
longlong item_value;
Name_resolution_context *context= &lex->current_select->context;
TABLE_LIST *save_list= context->table_list;
...
...
@@ -2900,13 +2912,18 @@ part_bit_expr:
context->table_list= save_list;
not_corr_func= !part_expr->const_item() ||
!lex->safe_to_cache_query;
lex->safe_to_cache_query= 1;
if (not_corr_func)
{
yyerror(ER(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR));
YYABORT;
}
$$= part_expr;
if (part_expr->result_type() != INT_RESULT)
{
yyerror(ER(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR));
YYABORT;
}
item_value= part_expr->val_int();
$$= item_value;
}
opt_sub_partition:
...
...
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