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
ae2192ed
Commit
ae2192ed
authored
Nov 22, 2002
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved safe_to_cache_query from thd to lex.
This is required for prepared statements and stored procedures.
parent
b201dfec
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
44 additions
and
39 deletions
+44
-39
.bzrignore
.bzrignore
+5
-0
sql/item_create.cc
sql/item_create.cc
+7
-7
sql/item_func.cc
sql/item_func.cc
+2
-2
sql/sql_cache.cc
sql/sql_cache.cc
+5
-5
sql/sql_class.cc
sql/sql_class.cc
+1
-1
sql/sql_class.h
sql/sql_class.h
+0
-1
sql/sql_lex.cc
sql/sql_lex.cc
+2
-1
sql/sql_lex.h
sql/sql_lex.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+0
-1
sql/sql_prepare.cc
sql/sql_prepare.cc
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+20
-20
No files found.
.bzrignore
View file @
ae2192ed
...
...
@@ -557,3 +557,8 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
bkpull.log
bkpull.log.2
bkpull.log.3
build.log
sql/safe_to_cache_query.txt
sql/item_create.cc
View file @
ae2192ed
...
...
@@ -76,7 +76,7 @@ Item *create_func_ceiling(Item* a)
Item
*
create_func_connection_id
(
void
)
{
THD
*
thd
=
current_thd
;
thd
->
safe_to_cache_query
=
0
;
thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_int
(
"CONNECTION_ID()"
,(
longlong
)
thd
->
thread_id
,
10
);
}
...
...
@@ -149,7 +149,7 @@ Item *create_func_floor(Item* a)
Item
*
create_func_found_rows
(
void
)
{
THD
*
thd
=
current_thd
;
thd
->
safe_to_cache_query
=
0
;
thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_int
(
"FOUND_ROWS()"
,(
longlong
)
thd
->
found_rows
(),
21
);
}
...
...
@@ -160,7 +160,7 @@ Item *create_func_from_days(Item* a)
Item
*
create_func_get_lock
(
Item
*
a
,
Item
*
b
)
{
current_thd
->
safe_to_cache_query
=
0
;
current_thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_func_get_lock
(
a
,
b
);
}
...
...
@@ -308,7 +308,7 @@ Item *create_func_radians(Item *a)
Item
*
create_func_release_lock
(
Item
*
a
)
{
current_thd
->
safe_to_cache_query
=
0
;
current_thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_func_release_lock
(
a
);
}
...
...
@@ -416,13 +416,13 @@ Item *create_func_year(Item* a)
Item
*
create_load_file
(
Item
*
a
)
{
current_thd
->
safe_to_cache_query
=
0
;
current_thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_load_file
(
a
);
}
Item
*
create_wait_for_master_pos
(
Item
*
a
,
Item
*
b
)
{
current_thd
->
safe_to_cache_query
=
0
;
current_thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_master_pos_wait
(
a
,
b
);
}
...
...
@@ -443,7 +443,7 @@ Item *create_func_cast(Item *a, Item_cast cast_type)
Item
*
create_func_is_free_lock
(
Item
*
a
)
{
current_thd
->
safe_to_cache_query
=
0
;
current_thd
->
lex
.
safe_to_cache_query
=
0
;
return
new
Item_func_is_free_lock
(
a
);
}
...
...
sql/item_func.cc
View file @
ae2192ed
...
...
@@ -2470,7 +2470,7 @@ Item *get_system_var(enum_var_type var_type, LEX_STRING name)
}
if
(
!
(
item
=
var
->
item
(
thd
,
var_type
)))
return
0
;
// Impossible
thd
->
safe_to_cache_query
=
0
;
thd
->
lex
.
safe_to_cache_query
=
0
;
buff
[
0
]
=
'@'
;
buff
[
1
]
=
'@'
;
pos
=
buff
+
2
;
...
...
@@ -2496,7 +2496,7 @@ Item *get_system_var(enum_var_type var_type, const char *var_name, uint length,
DBUG_ASSERT
(
var
!=
0
);
if
(
!
(
item
=
var
->
item
(
thd
,
var_type
)))
return
0
;
// Impossible
thd
->
safe_to_cache_query
=
0
;
thd
->
lex
.
safe_to_cache_query
=
0
;
item
->
set_name
(
item_name
);
// Will use original name
return
item
;
}
...
...
sql/sql_cache.cc
View file @
ae2192ed
...
...
@@ -289,7 +289,7 @@ TODO list:
if (thd->temp_tables || global_merge_table_count)
- Another option would be to set thd->safe_to_cache_query to 0
- Another option would be to set thd->
lex.
safe_to_cache_query to 0
in 'get_lock_data' if any of the tables was a tmp table or a
MRG_ISAM table.
(This could be done with almost no speed penalty)
...
...
@@ -900,7 +900,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
/* Check that we haven't forgot to reset the query cache variables */
DBUG_ASSERT
(
thd
->
net
.
query_cache_query
==
0
);
if
(
!
thd
->
safe_to_cache_query
)
if
(
!
thd
->
lex
.
safe_to_cache_query
)
{
DBUG_PRINT
(
"qcache"
,
(
"SELECT is non-cacheable"
));
goto
err
;
...
...
@@ -994,7 +994,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
table_list
.
db
,
table_list
.
alias
));
refused
++
;
// This is actually a hit
STRUCT_UNLOCK
(
&
structure_guard_mutex
);
thd
->
safe_to_cache_query
=
0
;
// Don't try to cache this
thd
->
lex
.
safe_to_cache_query
=
0
;
// Don't try to cache this
BLOCK_UNLOCK_RD
(
query_block
);
DBUG_RETURN
(
-
1
);
// Privilege error
}
...
...
@@ -1003,7 +1003,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT
(
"qcache"
,
(
"Need to check column privileges for %s.%s"
,
table_list
.
db
,
table_list
.
alias
));
BLOCK_UNLOCK_RD
(
query_block
);
thd
->
safe_to_cache_query
=
0
;
// Don't try to cache this
thd
->
lex
.
safe_to_cache_query
=
0
;
// Don't try to cache this
goto
err_unlock
;
// Parse query
}
}
...
...
@@ -2457,7 +2457,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
(
thd
->
variables
.
query_cache_type
==
1
||
(
thd
->
variables
.
query_cache_type
==
2
&&
(
lex
->
select_lex
.
options
&
OPTION_TO_QUERY_CACHE
)))
&&
thd
->
safe_to_cache_query
)
lex
->
safe_to_cache_query
)
{
my_bool
has_transactions
=
0
;
DBUG_PRINT
(
"qcache"
,
(
"options %lx %lx, type %u"
,
...
...
sql/sql_class.cc
View file @
ae2192ed
...
...
@@ -87,7 +87,7 @@ THD::THD():user_time(0), fatal_error(0),
host
=
user
=
priv_user
=
db
=
query
=
ip
=
0
;
host_or_ip
=
"unknown ip"
;
locked
=
killed
=
count_cuted_fields
=
some_tables_deleted
=
no_errors
=
password
=
query_start_used
=
safe_to_cache_query
=
prepare_command
=
0
;
query_start_used
=
prepare_command
=
0
;
db_length
=
query_length
=
col_access
=
0
;
query_error
=
0
;
next_insert_id
=
last_insert_id
=
0
;
...
...
sql/sql_class.h
View file @
ae2192ed
...
...
@@ -507,7 +507,6 @@ class THD :public ilink {
bool
query_start_used
,
last_insert_id_used
,
insert_id_used
,
rand_used
;
bool
system_thread
,
in_lock_tables
,
global_read_lock
;
bool
query_error
,
bootstrap
,
cleanup_done
;
bool
safe_to_cache_query
;
bool
volatile
killed
;
bool
prepare_command
;
Item_param
*
params
;
// Pointer to array of params
...
...
sql/sql_lex.cc
View file @
ae2192ed
...
...
@@ -154,6 +154,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
lex
->
ignore_space
=
test
(
thd
->
sql_mode
&
MODE_IGNORE_SPACE
);
lex
->
slave_thd_opt
=
0
;
lex
->
sql_command
=
SQLCOM_END
;
lex
->
safe_to_cache_query
=
1
;
bzero
(
&
lex
->
mi
,
sizeof
(
lex
->
mi
));
return
lex
;
}
...
...
@@ -182,7 +183,7 @@ static int find_keyword(LEX *lex, uint len, bool function)
udf_func
*
udf
;
if
(
function
&&
using_udf_functions
&&
(
udf
=
find_udf
((
char
*
)
tok
,
len
)))
{
lex
->
thd
->
safe_to_cache_query
=
0
;
lex
->
safe_to_cache_query
=
0
;
lex
->
yylval
->
udf
=
udf
;
switch
(
udf
->
returns
)
{
case
STRING_RESULT
:
...
...
sql/sql_lex.h
View file @
ae2192ed
...
...
@@ -440,6 +440,7 @@ typedef struct st_lex
bool
drop_primary
,
drop_if_exists
,
drop_temporary
,
local_file
;
bool
in_comment
,
ignore_space
,
verbose
,
simple_alter
;
bool
derived_tables
,
describe
,
olap
;
bool
safe_to_cache_query
;
uint
slave_thd_opt
;
CHARSET_INFO
*
charset
;
char
*
help_arg
;
...
...
sql/sql_parse.cc
View file @
ae2192ed
...
...
@@ -2875,7 +2875,6 @@ mysql_init_query(THD *thd)
thd
->
last_insert_id_used
=
thd
->
query_start_used
=
thd
->
insert_id_used
=
0
;
thd
->
sent_row_count
=
thd
->
examined_row_count
=
0
;
thd
->
fatal_error
=
thd
->
rand_used
=
0
;
thd
->
safe_to_cache_query
=
1
;
thd
->
possible_loops
=
0
;
DBUG_VOID_RETURN
;
}
...
...
sql/sql_prepare.cc
View file @
ae2192ed
...
...
@@ -606,9 +606,9 @@ static bool parse_prepare_query(PREP_STMT *stmt,
mysql_log
.
write
(
thd
,
COM_PREPARE
,
"%s"
,
packet
);
mysql_init_query
(
thd
);
thd
->
prepare_command
=
true
;
thd
->
safe_to_cache_query
=
0
;
LEX
*
lex
=
lex_start
(
thd
,
(
uchar
*
)
packet
,
length
);
lex
->
safe_to_cache_query
=
0
;
if
(
!
yyparse
()
&&
!
thd
->
fatal_error
)
error
=
send_prepare_results
(
stmt
);
lex_end
(
lex
);
...
...
sql/sql_yacc.yy
View file @
ae2192ed
...
...
@@ -1676,7 +1676,7 @@ select_option:
YYABORT;
Select->options|= OPTION_FOUND_ROWS;
}
| SQL_NO_CACHE_SYM {
current_thd
->safe_to_cache_query=0; }
| SQL_NO_CACHE_SYM {
Lex
->safe_to_cache_query=0; }
| SQL_CACHE_SYM { Select->options|= OPTION_TO_QUERY_CACHE; }
| ALL {}
;
...
...
@@ -1689,7 +1689,7 @@ select_lock_type:
if (check_simple_select())
YYABORT;
lex->lock_option= TL_WRITE;
lex->
thd->
safe_to_cache_query=0;
lex->safe_to_cache_query=0;
}
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
{
...
...
@@ -1697,7 +1697,7 @@ select_lock_type:
if (check_simple_select())
YYABORT;
lex->lock_option= TL_READ_WITH_SHARED_LOCKS;
lex->
thd->
safe_to_cache_query=0;
lex->safe_to_cache_query=0;
}
;
...
...
@@ -1885,12 +1885,12 @@ simple_expr:
| '@' ident_or_text SET_VAR expr
{
$$= new Item_func_set_user_var($2,$4);
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| '@' ident_or_text
{
$$= new Item_func_get_user_var($2);
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| '@' '@' opt_var_ident_type ident_or_text
{
...
...
@@ -1944,13 +1944,13 @@ simple_expr:
| CONCAT_WS '(' expr ',' expr_list ')'
{ $$= new Item_func_concat_ws($3, *$5); }
| CURDATE optional_braces
{ $$= new Item_func_curdate();
current_thd
->safe_to_cache_query=0; }
{ $$= new Item_func_curdate();
Lex
->safe_to_cache_query=0; }
| CURTIME optional_braces
{ $$= new Item_func_curtime();
current_thd
->safe_to_cache_query=0; }
{ $$= new Item_func_curtime();
Lex
->safe_to_cache_query=0; }
| CURTIME '(' expr ')'
{
$$= new Item_func_curtime($3);
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
{ $$= new Item_date_add_interval($3,$6,$7,0); }
...
...
@@ -1959,7 +1959,7 @@ simple_expr:
| DATABASE '(' ')'
{
$$= new Item_func_database();
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| ELT_FUNC '(' expr ',' expr_list ')'
{ $$= new Item_func_elt($3, *$5); }
...
...
@@ -1968,7 +1968,7 @@ simple_expr:
| ENCRYPT '(' expr ')'
{
$$= new Item_func_encrypt($3);
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); }
| DECODE_SYM '(' expr ',' TEXT_STRING ')'
...
...
@@ -2028,7 +2028,7 @@ simple_expr:
| LAST_INSERT_ID '(' expr ')'
{
$$= new Item_func_set_last_insert_id($3);
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| LEFT '(' expr ',' expr ')'
{ $$= new Item_func_left($3,$5); }
...
...
@@ -2083,9 +2083,9 @@ simple_expr:
{ $$= new Item_func_spatial_collection(* $3,
Geometry::wkbMultiPolygon, Geometry::wkbPolygon ); }
| NOW_SYM optional_braces
{ $$= new Item_func_now();
current_thd
->safe_to_cache_query=0;}
{ $$= new Item_func_now();
Lex
->safe_to_cache_query=0;}
| NOW_SYM '(' expr ')'
{ $$= new Item_func_now($3);
current_thd
->safe_to_cache_query=0;}
{ $$= new Item_func_now($3);
Lex
->safe_to_cache_query=0;}
| PASSWORD '(' expr ')'
{
$$= new Item_func_password($3);
...
...
@@ -2104,9 +2104,9 @@ simple_expr:
| POSITION_SYM '(' no_in_expr IN_SYM expr ')'
{ $$ = new Item_func_locate($5,$3); }
| RAND '(' expr ')'
{ $$= new Item_func_rand($3);
current_thd
->safe_to_cache_query=0;}
{ $$= new Item_func_rand($3);
Lex
->safe_to_cache_query=0;}
| RAND '(' ')'
{ $$= new Item_func_rand();
current_thd
->safe_to_cache_query=0;}
{ $$= new Item_func_rand();
Lex
->safe_to_cache_query=0;}
| REPLACE '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_replace($3,$5,$7); }
| RIGHT '(' expr ',' expr ')'
...
...
@@ -2189,12 +2189,12 @@ simple_expr:
| UNIX_TIMESTAMP '(' ')'
{
$$= new Item_func_unix_timestamp();
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| UNIX_TIMESTAMP '(' expr ')'
{ $$= new Item_func_unix_timestamp($3); }
| USER '(' ')'
{ $$= new Item_func_user();
current_thd
->safe_to_cache_query=0; }
{ $$= new Item_func_user();
Lex
->safe_to_cache_query=0; }
| WEEK_SYM '(' expr ')'
{ $$= new Item_func_week($3,new Item_int((char*) "0",0,1)); }
| WEEK_SYM '(' expr ',' expr ')'
...
...
@@ -2208,7 +2208,7 @@ simple_expr:
| BENCHMARK_SYM '(' ULONG_NUM ',' expr ')'
{
$$=new Item_func_benchmark($3,$5);
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
| EXTRACT_SYM '(' interval FROM expr ')'
{ $$=new Item_extract( $3, $5); };
...
...
@@ -2667,7 +2667,7 @@ procedure_clause:
lex->proc_list.next= (byte**) &lex->proc_list.first;
if (add_proc_to_list(new Item_field(NULL,NULL,$2.str)))
YYABORT;
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
'(' procedure_list ')';
...
...
@@ -2739,7 +2739,7 @@ opt_into:
}
| INTO select_var_list_init
{
current_thd
->safe_to_cache_query=0;
Lex
->safe_to_cache_query=0;
}
;
...
...
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