diff options
author | unknown <pem@mysql.com> | 2002-11-22 14:50:53 +0100 |
---|---|---|
committer | unknown <pem@mysql.com> | 2002-11-22 14:50:53 +0100 |
commit | 0e9a75a4f7151ea7930a5eaddfc91fd210873f16 (patch) | |
tree | 59f235951aa3f228fa16706b3361d8b9f2c303f4 /sql | |
parent | 5a70f257c9d7dfd6677eca3301127bf455e6d6d6 (diff) | |
download | mariadb-git-0e9a75a4f7151ea7930a5eaddfc91fd210873f16.tar.gz |
Moved safe_to_cache_query from thd to lex.
This is required for prepared statements and stored procedures.
BitKeeper/etc/ignore:
Added bkpull.log bkpull.log.2 bkpull.log.3 build.log sql/safe_to_cache_query.txt to the ignore list
sql/item_create.cc:
Moved safe_to_cache_query from thd to lex.
sql/item_func.cc:
Moved safe_to_cache_query from thd to lex.
sql/sql_cache.cc:
Moved safe_to_cache_query from thd to lex.
Note: Query_cache::is_cacheable() has both a thd and lex argument.
We assumed that it's the lex->safe_to_cache_query we should test.
sql/sql_class.cc:
Moved safe_to_cache_query from thd to lex.
sql/sql_class.h:
Moved safe_to_cache_query from thd to lex.
sql/sql_lex.cc:
Moved safe_to_cache_query from thd to lex.
We set it to 1 initially. It's then set to 0 in cases where
it's know not to be safe. (Before this change, it was set to
0 in thd, and then set to 1 before parsing.)
sql/sql_lex.h:
Moved safe_to_cache_query from thd to lex.
sql/sql_parse.cc:
Moved safe_to_cache_query from thd to lex.
No point in setting it here now, it's set in lex_start() later.
sql/sql_prepare.cc:
Moved safe_to_cache_query from thd to lex.
Must set it after lex_start() has been called.
sql/sql_yacc.yy:
Moved safe_to_cache_query from thd to lex.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_create.cc | 14 | ||||
-rw-r--r-- | sql/item_func.cc | 4 | ||||
-rw-r--r-- | sql/sql_cache.cc | 10 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_class.h | 1 | ||||
-rw-r--r-- | sql/sql_lex.cc | 3 | ||||
-rw-r--r-- | sql/sql_lex.h | 1 | ||||
-rw-r--r-- | sql/sql_parse.cc | 1 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 40 |
10 files changed, 39 insertions, 39 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index e4c9a160686..ad9058c1691 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -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); } diff --git a/sql/item_func.cc b/sql/item_func.cc index 75260065be6..e28fda0340e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -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; } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index ef584f4364e..aa0f5824b4e 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -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", diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4141211ad92..9bca7245cba 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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; diff --git a/sql/sql_class.h b/sql/sql_class.h index acdf2471ba8..e64cfbc198a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -507,7 +507,6 @@ public: 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 diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 9ed66aede6f..e3ffe2a8120 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -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: diff --git a/sql/sql_lex.h b/sql/sql_lex.h index dd41af4b250..fa4eca80ee2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -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; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 263ac50120d..4e5f0019ad6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 08377a10501..527878596f4 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -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); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index eaae24d0310..5dcb4f09951 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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; } ; |