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
cb19ad9a
Commit
cb19ad9a
authored
Nov 17, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed using 'uncachable' tag and RAND_TABLE_BIT setting
parent
74165e72
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
60 deletions
+62
-60
sql/item_create.cc
sql/item_create.cc
+5
-5
sql/item_func.cc
sql/item_func.cc
+2
-2
sql/item_subselect.cc
sql/item_subselect.cc
+13
-22
sql/item_subselect.h
sql/item_subselect.h
+4
-8
sql/mysql_priv.h
sql/mysql_priv.h
+5
-0
sql/sql_lex.cc
sql/sql_lex.cc
+5
-4
sql/sql_lex.h
sql/sql_lex.h
+11
-4
sql/sql_select.cc
sql/sql_select.cc
+4
-2
sql/sql_union.cc
sql/sql_union.cc
+2
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+11
-11
No files found.
sql/item_create.cc
View file @
cb19ad9a
...
...
@@ -159,7 +159,7 @@ Item *create_func_from_days(Item* a)
Item
*
create_func_get_lock
(
Item
*
a
,
Item
*
b
)
{
current_thd
->
lex
.
uncacheable
();
current_thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
return
new
Item_func_get_lock
(
a
,
b
);
}
...
...
@@ -324,7 +324,7 @@ Item *create_func_radians(Item *a)
Item
*
create_func_release_lock
(
Item
*
a
)
{
current_thd
->
lex
.
uncacheable
();
current_thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
return
new
Item_func_release_lock
(
a
);
}
...
...
@@ -445,7 +445,7 @@ Item *create_func_year(Item* a)
Item
*
create_load_file
(
Item
*
a
)
{
current_thd
->
lex
.
uncacheable
();
current_thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
return
new
Item_load_file
(
a
);
}
...
...
@@ -472,13 +472,13 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len,
Item
*
create_func_is_free_lock
(
Item
*
a
)
{
current_thd
->
lex
.
uncacheable
();
current_thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
return
new
Item_func_is_free_lock
(
a
);
}
Item
*
create_func_is_used_lock
(
Item
*
a
)
{
current_thd
->
lex
.
uncacheable
();
current_thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
return
new
Item_func_is_used_lock
(
a
);
}
...
...
sql/item_func.cc
View file @
cb19ad9a
...
...
@@ -2947,7 +2947,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
}
if
(
!
(
item
=
var
->
item
(
thd
,
var_type
,
component_name
)))
return
0
;
// Impossible
thd
->
lex
.
uncacheable
();
thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
buff
[
0
]
=
'@'
;
buff
[
1
]
=
'@'
;
pos
=
buff
+
2
;
...
...
@@ -2987,7 +2987,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, const char *var_name,
DBUG_ASSERT
(
var
!=
0
);
if
(
!
(
item
=
var
->
item
(
thd
,
var_type
,
&
null_lex_string
)))
return
0
;
// Impossible
thd
->
lex
.
uncacheable
();
thd
->
lex
.
uncacheable
(
UNCACHEABLE_UNCACHEABLE
);
item
->
set_name
(
item_name
,
0
,
system_charset_info
);
// Will use original name
return
item
;
}
...
...
sql/item_subselect.cc
View file @
cb19ad9a
...
...
@@ -111,10 +111,12 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref)
}
fix_length_and_dec
();
}
if
(
engine
->
uncacheable
())
uint8
uncacheable
=
engine
->
uncacheable
();
if
(
uncacheable
)
{
const_item_cache
=
0
;
used_tables_cache
|=
RAND_TABLE_BIT
;
if
(
uncacheable
&
UNCACHEABLE_RAND
)
used_tables_cache
|=
RAND_TABLE_BIT
;
}
fixed
=
1
;
thd
->
where
=
save_where
;
...
...
@@ -155,7 +157,7 @@ void Item_subselect::fix_length_and_dec()
table_map
Item_subselect
::
used_tables
()
const
{
return
(
table_map
)
(
engine
->
dependent
()
?
used_tables_cache
:
0L
);
return
(
table_map
)
(
engine
->
uncacheable
()
?
used_tables_cache
:
0L
);
}
...
...
@@ -558,7 +560,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
}
if
((
abort_on_null
||
(
upper_not
&&
upper_not
->
top_level
()))
&&
!
select_lex
->
master_unit
()
->
dependent
&&
!
func
->
eqne_op
())
!
select_lex
->
master_unit
()
->
uncacheable
&&
!
func
->
eqne_op
())
{
if
(
substitution
)
{
...
...
@@ -644,10 +646,10 @@ Item_in_subselect::single_value_transformer(JOIN *join,
(
char
*
)
"<no matter>"
,
(
char
*
)
in_left_expr_name
);
unit
->
dependent
=
unit
->
uncacheable
=
1
;
unit
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
}
select_lex
->
dependent
=
select_lex
->
uncacheable
=
1
;
select_lex
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
Item
*
item
;
item
=
(
Item
*
)
select_lex
->
item_list
.
head
();
...
...
@@ -768,12 +770,12 @@ Item_in_subselect::row_value_transformer(JOIN *join)
DBUG_RETURN
(
RES_ERROR
);
}
thd
->
lex
.
current_select
=
current
;
unit
->
dependent
=
unit
->
uncacheable
=
1
;
unit
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
}
uint
n
=
left_expr
->
cols
();
select_lex
->
dependent
=
select_lex
->
uncacheable
=
1
;
select_lex
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
select_lex
->
setup_ref_array
(
thd
,
select_lex
->
order_list
.
elements
+
select_lex
->
group_list
.
elements
);
...
...
@@ -1047,7 +1049,7 @@ int subselect_single_select_engine::exec()
DBUG_RETURN
(
1
);
}
}
if
(
(
select_lex
->
dependent
||
select_lex
->
uncacheable
)
&&
executed
)
if
(
select_lex
->
uncacheable
&&
executed
)
{
if
(
join
->
reinit
())
{
...
...
@@ -1199,24 +1201,13 @@ uint subselect_union_engine::cols()
}
bool
subselect_single_select_engine
::
dependent
()
{
return
select_lex
->
dependent
;
}
bool
subselect_union_engine
::
dependent
()
{
return
unit
->
dependent
;
}
bool
subselect_single_select_engine
::
uncacheable
()
uint8
subselect_single_select_engine
::
uncacheable
()
{
return
select_lex
->
uncacheable
;
}
bool
subselect_union_engine
::
uncacheable
()
uint8
subselect_union_engine
::
uncacheable
()
{
return
unit
->
uncacheable
;
}
...
...
sql/item_subselect.h
View file @
cb19ad9a
...
...
@@ -269,8 +269,7 @@ class subselect_engine: public Sql_alloc
virtual
void
fix_length_and_dec
(
Item_cache
**
row
)
=
0
;
virtual
int
exec
()
=
0
;
virtual
uint
cols
()
=
0
;
/* return number of columnss in select */
virtual
bool
dependent
()
=
0
;
/* depended from outer select */
virtual
bool
uncacheable
()
=
0
;
/* query is uncacheable */
virtual
uint8
uncacheable
()
=
0
;
/* query is uncacheable */
enum
Item_result
type
()
{
return
res_type
;
}
virtual
void
exclude
()
=
0
;
bool
may_be_null
()
{
return
maybe_null
;
};
...
...
@@ -295,8 +294,7 @@ class subselect_single_select_engine: public subselect_engine
void
fix_length_and_dec
(
Item_cache
**
row
);
int
exec
();
uint
cols
();
bool
dependent
();
bool
uncacheable
();
uint8
uncacheable
();
void
exclude
();
table_map
upper_select_const_tables
();
void
print
(
String
*
str
);
...
...
@@ -314,8 +312,7 @@ class subselect_union_engine: public subselect_engine
void
fix_length_and_dec
(
Item_cache
**
row
);
int
exec
();
uint
cols
();
bool
dependent
();
bool
uncacheable
();
uint8
uncacheable
();
void
exclude
();
table_map
upper_select_const_tables
();
void
print
(
String
*
str
);
...
...
@@ -342,8 +339,7 @@ class subselect_uniquesubquery_engine: public subselect_engine
void
fix_length_and_dec
(
Item_cache
**
row
);
int
exec
();
uint
cols
()
{
return
1
;
}
bool
dependent
()
{
return
1
;
}
bool
uncacheable
()
{
return
1
;
}
uint8
uncacheable
()
{
return
UNCACHEABLE_DEPENDENT
;
}
void
exclude
();
table_map
upper_select_const_tables
()
{
return
0
;
}
void
print
(
String
*
str
);
...
...
sql/mysql_priv.h
View file @
cb19ad9a
...
...
@@ -248,6 +248,11 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
#define MY_CHARSET_BIN_MB_MAXLEN 1
// uncachable cause
#define UNCACHEABLE_DEPENDENT 1
#define UNCACHEABLE_RAND 2
#define UNCACHEABLE_UNCACHEABLE 4
#ifdef EXTRA_DEBUG
/*
Sync points allow us to force the server to reach a certain line of code
...
...
sql/sql_lex.cc
View file @
cb19ad9a
...
...
@@ -965,7 +965,8 @@ void st_select_lex_node::init_query()
{
options
=
0
;
linkage
=
UNSPECIFIED_TYPE
;
no_error
=
no_table_names_allowed
=
uncacheable
=
dependent
=
0
;
no_error
=
no_table_names_allowed
=
0
;
uncacheable
=
0
;
}
void
st_select_lex_node
::
init_select
()
...
...
@@ -1215,12 +1216,12 @@ void st_select_lex::mark_as_dependent(SELECT_LEX *last)
for
(
SELECT_LEX
*
s
=
this
;
s
&&
s
!=
last
;
s
=
s
->
outer_select
())
if
(
!
s
->
dependent
)
if
(
!
(
s
->
uncacheable
&
UNCACHEABLE_DEPENDENT
)
)
{
// Select is dependent of outer select
s
->
dependent
=
s
->
uncacheable
=
1
;
s
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
SELECT_LEX_UNIT
*
munit
=
s
->
master_unit
();
munit
->
dependent
=
munit
->
uncacheable
=
1
;
munit
->
uncacheable
|=
UNCACHEABLE_DEPENDENT
;
//Tables will be reopened many times
for
(
TABLE_LIST
*
tbl
=
s
->
get_table_list
();
tbl
;
...
...
sql/sql_lex.h
View file @
cb19ad9a
...
...
@@ -84,6 +84,7 @@ enum enum_sql_command {
#define DESCRIBE_NORMAL 1
#define DESCRIBE_EXTENDED 2
typedef
List
<
Item
>
List_item
;
typedef
struct
st_lex_master_info
...
...
@@ -226,9 +227,14 @@ class st_select_lex_node {
};
ulong
options
;
/*
result of this query can't be cached, bit field, can be :
UNCACHEABLE_DEPENDENT
UNCACHEABLE_RAND
UNCACHEABLE_UNCACHEABLE
*/
uint8
uncacheable
;
enum
sub_select_type
linkage
;
bool
dependent
;
/* dependent from outer select subselect */
bool
uncacheable
;
/* result of this query can't be cached */
bool
no_table_names_allowed
;
/* used for global order by */
bool
no_error
;
/* suppress error message (convert it to warnings) */
...
...
@@ -565,7 +571,7 @@ typedef struct st_lex
bool
derived_tables
;
bool
safe_to_cache_query
;
st_lex
()
{}
inline
void
uncacheable
()
inline
void
uncacheable
(
uint8
cause
)
{
safe_to_cache_query
=
0
;
...
...
@@ -580,7 +586,8 @@ typedef struct st_lex
un
!=
&
unit
;
sl
=
sl
->
outer_select
(),
un
=
sl
->
master_unit
())
{
sl
->
uncacheable
=
un
->
uncacheable
=
1
;
sl
->
uncacheable
|=
cause
;
un
->
uncacheable
|=
cause
;
}
}
}
LEX
;
...
...
sql/sql_select.cc
View file @
cb19ad9a
...
...
@@ -9041,10 +9041,12 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
((
sl
==
first
)
?
((
sl
->
linkage
==
DERIVED_TABLE_TYPE
)
?
"DERIVED"
:
((
sl
->
dependent
)
?
"DEPENDENT SUBQUERY"
:
((
sl
->
uncacheable
&
UNCACHEABLE_DEPENDENT
)
?
"DEPENDENT SUBQUERY"
:
(
sl
->
uncacheable
?
"UNCACHEABLE SUBQUERY"
:
"SUBQUERY"
)))
:
((
sl
->
dependent
)
?
"DEPENDENT UNION"
:
((
sl
->
uncacheable
&
UNCACHEABLE_DEPENDENT
)
?
"DEPENDENT UNION"
:
sl
->
uncacheable
?
"UNCACHEABLE UNION"
:
"UNION"
))),
result
);
...
...
sql/sql_union.cc
View file @
cb19ad9a
...
...
@@ -249,11 +249,11 @@ int st_select_lex_unit::exec()
ulonglong
add_rows
=
0
;
DBUG_ENTER
(
"st_select_lex_unit::exec"
);
if
(
executed
&&
!
(
dependent
||
uncacheable
)
)
if
(
executed
&&
!
uncacheable
)
DBUG_RETURN
(
0
);
executed
=
1
;
if
(
(
dependent
||
uncacheable
)
||
!
item
||
!
item
->
assigned
())
if
(
uncacheable
||
!
item
||
!
item
->
assigned
())
{
if
(
optimized
&&
item
&&
item
->
assigned
())
{
...
...
sql/sql_yacc.yy
View file @
cb19ad9a
...
...
@@ -2197,7 +2197,7 @@ select_option:
YYABORT;
Select->options|= OPTION_FOUND_ROWS;
}
| SQL_NO_CACHE_SYM { Lex->
uncacheable()
; }
| SQL_NO_CACHE_SYM { Lex->
safe_to_cache_query=0
; }
| SQL_CACHE_SYM
{
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
...
...
@@ -2466,12 +2466,12 @@ simple_expr:
| '@' ident_or_text SET_VAR expr
{
$$= new Item_func_set_user_var($2,$4);
Lex->uncacheable();
Lex->uncacheable(
UNCACHEABLE_RAND
);
}
| '@' ident_or_text
{
$$= new Item_func_get_user_var($2);
Lex->uncacheable();
Lex->uncacheable(
UNCACHEABLE_RAND
);
}
| '@' '@' opt_var_ident_type ident_or_text opt_component
{
...
...
@@ -2587,7 +2587,7 @@ simple_expr:
| ENCRYPT '(' expr ')'
{
$$= new Item_func_encrypt($3);
Lex->uncacheable();
Lex->uncacheable(
UNCACHEABLE_RAND
);
}
| ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); }
| DECODE_SYM '(' expr ',' TEXT_STRING_literal ')'
...
...
@@ -2755,9 +2755,9 @@ simple_expr:
| POSITION_SYM '(' no_in_expr IN_SYM expr ')'
{ $$ = new Item_func_locate($5,$3); }
| RAND '(' expr ')'
{ $$= new Item_func_rand($3); Lex->uncacheable();}
{ $$= new Item_func_rand($3); Lex->uncacheable(
UNCACHEABLE_RAND
);}
| RAND '(' ')'
{ $$= new Item_func_rand(); Lex->uncacheable();}
{ $$= new Item_func_rand(); Lex->uncacheable(
UNCACHEABLE_RAND
);}
| REPLACE '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_replace($3,$5,$7); }
| RIGHT '(' expr ',' expr ')'
...
...
@@ -2884,7 +2884,7 @@ simple_expr:
| BENCHMARK_SYM '(' ULONG_NUM ',' expr ')'
{
$$=new Item_func_benchmark($3,$5);
Lex->uncacheable();
Lex->uncacheable(
UNCACHEABLE_UNCACHEABLE
);
}
| EXTRACT_SYM '(' interval FROM expr ')'
{ $$=new Item_extract( $3, $5); };
...
...
@@ -3464,7 +3464,7 @@ procedure_clause:
lex->proc_list.next= (byte**) &lex->proc_list.first;
if (add_proc_to_list(lex->thd, new Item_field(NULL,NULL,$2.str)))
YYABORT;
Lex->uncacheable();
Lex->uncacheable(
UNCACHEABLE_UNCACHEABLE
);
}
'(' procedure_list ')';
...
...
@@ -3518,7 +3518,7 @@ into:
LEX *lex=Lex;
if (!lex->describe)
{
lex->uncacheable();
lex->uncacheable(
UNCACHEABLE_UNCACHEABLE
);
if (!(lex->exchange= new sql_exchange($3.str,0)))
YYABORT;
if (!(lex->result= new select_export(lex->exchange)))
...
...
@@ -3531,7 +3531,7 @@ into:
LEX *lex=Lex;
if (!lex->describe)
{
lex->uncacheable();
lex->uncacheable(
UNCACHEABLE_UNCACHEABLE
);
if (!(lex->exchange= new sql_exchange($3.str,1)))
YYABORT;
if (!(lex->result= new select_dump(lex->exchange)))
...
...
@@ -3540,7 +3540,7 @@ into:
}
| INTO select_var_list_init
{
Lex->uncacheable();
Lex->uncacheable(
UNCACHEABLE_UNCACHEABLE
);
}
;
...
...
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