summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-05-05 21:24:13 +0300
committerunknown <bell@sanja.is.com.ua>2004-05-05 21:24:13 +0300
commit2c95f97c2beea7b88378623d9655fcf2ad88a9a9 (patch)
treeb08dcc78213fe6542cd07701d30fdab61f2ac232 /sql
parentb30d0883b1e87df5a476a9e48542321de4384aa4 (diff)
parentf6428e8bb9ac0cad24465513c5969a50cd13f6f2 (diff)
downloadmariadb-git-2c95f97c2beea7b88378623d9655fcf2ad88a9a9.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-ndb-4.1 mysql-test/r/subselect.result: Auto merged sql/sql_lex.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_union.cc: Auto merged sql/sql_update.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_isammrg.h1
-rw-r--r--sql/ha_ndbcluster.h4
-rw-r--r--sql/handler.h6
-rw-r--r--sql/sql_cache.cc7
-rw-r--r--sql/sql_lex.cc6
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_parse.cc17
-rw-r--r--sql/sql_union.cc15
-rw-r--r--sql/sql_update.cc13
-rw-r--r--sql/sql_yacc.yy13
10 files changed, 43 insertions, 41 deletions
diff --git a/sql/ha_isammrg.h b/sql/ha_isammrg.h
index 05c1d862eb3..289277a9dac 100644
--- a/sql/ha_isammrg.h
+++ b/sql/ha_isammrg.h
@@ -68,4 +68,5 @@ class ha_isammrg: public handler
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
+ uint8 table_cache_type() { return HA_CACHE_TBL_NOCACHE; }
};
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index ed66d07d79b..bd601f39fc4 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -107,7 +107,7 @@ class ha_ndbcluster: public handler
return true;
#endif
}
- bool has_transactions() { return true;}
+ bool has_transactions() { return true; }
const char* index_type(uint key_number) {
switch (get_index_type(key_number)) {
@@ -130,7 +130,7 @@ class ha_ndbcluster: public handler
static Ndb* seize_ndb();
static void release_ndb(Ndb* ndb);
-
+ uint8 table_cache_type() { return HA_CACHE_TBL_NOCACHE; }
private:
int alter_table_name(const char *from, const char *to);
diff --git a/sql/handler.h b/sql/handler.h
index 62ff74c436a..ac5dceba8ab 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -138,8 +138,10 @@
/* Table caching type */
#define HA_CACHE_TBL_NONTRANSACT 0
-#define HA_CACHE_TBL_ASKTRANSACT 1
-#define HA_CACHE_TBL_TRANSACT 2
+#define HA_CACHE_TBL_NOCACHE 1
+#define HA_CACHE_TBL_ASKTRANSACT 2
+#define HA_CACHE_TBL_TRANSACT 4
+
enum db_type
{
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index e1a15eff475..359150cf716 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2612,14 +2612,15 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
table_alias_charset used here because it depends of
lower_case_table_names variable
*/
- if (tables_used->table->db_type == DB_TYPE_MRG_ISAM ||
- tables_used->table->tmp_table != NO_TMP_TABLE ||
+ if (tables_used->table->tmp_table != NO_TMP_TABLE ||
+ (*tables_type & HA_CACHE_TBL_NOCACHE) ||
(tables_used->db_length == 5 &&
my_strnncoll(table_alias_charset, (uchar*)tables_used->db, 6,
(uchar*)"mysql",6) == 0))
{
DBUG_PRINT("qcache",
- ("select not cacheable: used MRG_ISAM, temporary or system table(s)"));
+ ("select not cacheable: temporary, system or \
+other non-cacheable table(s)"));
DBUG_RETURN(0);
}
if (tables_used->table->db_type == DB_TYPE_MRG_MYISAM)
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 63247a64319..5fa8b37285e 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1023,6 +1023,7 @@ void st_select_lex::init_query()
ref_pointer_array= 0;
select_n_having_items= 0;
prep_where= 0;
+ explicit_limit= 0;
}
void st_select_lex::init_select()
@@ -1616,10 +1617,7 @@ void st_select_lex::print_limit(THD *thd, String *str)
if (!thd)
thd= current_thd;
- if ((select_limit != thd->variables.select_limit &&
- this == &thd->lex->select_lex) ||
- (select_limit != HA_POS_ERROR && this != &thd->lex->select_lex) ||
- offset_limit != 0L)
+ if (explicit_limit)
{
str->append(" limit ", 7);
char buff[20];
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index ea1accabf37..50f13a0391c 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -418,6 +418,8 @@ public:
bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */
/* TRUE when having fix field called in processing of this SELECT */
bool having_fix_field;
+ /* explicit LIMIT clause was used */
+ bool explicit_limit;
/*
SELECT for SELECT command st_select_lex. Used to privent scaning
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e0bb03a7002..98f6a12ec64 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1875,7 +1875,7 @@ mysql_execute_command(THD *thd)
if (&lex->select_lex != lex->all_selects_list &&
lex->unit.create_total_list(thd, lex, &tables))
DBUG_VOID_RETURN;
-
+
/*
When option readonly is set deny operations which change tables.
Except for the replication thread and the 'super' users.
@@ -1892,6 +1892,13 @@ mysql_execute_command(THD *thd)
switch (lex->sql_command) {
case SQLCOM_SELECT:
{
+ /* assign global limit variable if limit is not given */
+ {
+ SELECT_LEX *param= lex->unit.global_parameters;
+ if (!param->explicit_limit)
+ param->select_limit= thd->variables.select_limit;
+ }
+
select_result *result=lex->result;
if (tables)
{
@@ -3743,9 +3750,7 @@ mysql_init_select(LEX *lex)
{
SELECT_LEX *select_lex= lex->current_select;
select_lex->init_select();
- select_lex->select_limit= (&lex->select_lex == select_lex) ?
- lex->thd->variables.select_limit : /* Primry UNION */
- HA_POS_ERROR; /* subquery */
+ select_lex->select_limit= HA_POS_ERROR;
if (select_lex == &lex->select_lex)
{
lex->exchange= 0;
@@ -3797,9 +3802,7 @@ mysql_new_select(LEX *lex, bool move_down)
fake->select_number= INT_MAX;
fake->make_empty_select();
fake->linkage= GLOBAL_OPTIONS_TYPE;
- fake->select_limit= (&lex->unit == unit) ?
- lex->thd->variables.select_limit : /* Primry UNION */
- HA_POS_ERROR; /* subquery */
+ fake->select_limit= HA_POS_ERROR;
}
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 0dcf9f4731b..84468313b4f 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -376,21 +376,12 @@ int st_select_lex_unit::exec()
if (!thd->is_fatal_error) // Check if EOM
{
ulong options_tmp= thd->options;
- /*
- We have to take into the account a case when:
- SET SQL_SELECT_LIMIT was set.
- In mysql_new_select() function this value was copied to
- the fake_select_lex node of the top-level unit.
- Here below, we just take this value if global LIMIT was not applied
- to the entire UNION.
- */
- ha_rows select_limit= ((global_parameters->select_limit != HA_POS_ERROR) ?
- global_parameters->select_limit : fake_select_lex->select_limit);
thd->lex->current_select= fake_select_lex;
offset_limit_cnt= global_parameters->offset_limit;
- select_limit_cnt= select_limit + global_parameters->offset_limit;
+ select_limit_cnt= global_parameters->select_limit +
+ global_parameters->offset_limit;
- if (select_limit_cnt < select_limit)
+ if (select_limit_cnt < global_parameters->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
if (select_limit_cnt == HA_POS_ERROR)
options_tmp&= ~OPTION_FOUND_ROWS;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 3ae4ecad1e6..2428aac2da5 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -542,7 +542,7 @@ int mysql_multi_update(THD *thd,
}
}
- if (!(result=new multi_update(thd, table_list, fields, values,
+ if (!(result=new multi_update(thd, update_list, fields, values,
handle_duplicates)))
DBUG_RETURN(-1);
@@ -576,7 +576,7 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
int multi_update::prepare(List<Item> &not_used_values,
SELECT_LEX_UNIT *lex_unit)
{
- TABLE_LIST *table_ref, *tables;
+ TABLE_LIST *table_ref;
SQL_LIST update;
table_map tables_to_update= 0;
Item_field *item;
@@ -602,9 +602,8 @@ int multi_update::prepare(List<Item> &not_used_values,
We have to check values after setup_tables to get used_keys right in
reference tables
*/
- tables= thd->lex->select_lex.get_table_list();
- if (setup_fields(thd, 0, tables, *values, 1, 0, 0))
+ if (setup_fields(thd, 0, all_tables, *values, 1, 0, 0))
DBUG_RETURN(1);
/*
@@ -614,7 +613,7 @@ int multi_update::prepare(List<Item> &not_used_values,
*/
update.empty();
- for (table_ref= tables; table_ref; table_ref=table_ref->next)
+ for (table_ref= all_tables; table_ref; table_ref=table_ref->next)
{
TABLE *table=table_ref->table;
if (tables_to_update & table->map)
@@ -683,10 +682,10 @@ int multi_update::prepare(List<Item> &not_used_values,
which will cause an error when reading a row.
(This issue is mostly relevent for MyISAM tables)
*/
- for (table_ref= tables; table_ref; table_ref=table_ref->next)
+ for (table_ref= all_tables; table_ref; table_ref=table_ref->next)
{
TABLE *table=table_ref->table;
- if (!(tables_to_update & table->map) || !table->no_keyread &&
+ if (!(tables_to_update & table->map) &&
find_real_table_in_list(update_tables, table_ref->db,
table_ref->real_name))
table->no_cache= 1; // Disable row cache
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 568a526fd58..2155aa7e80f 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3566,9 +3566,7 @@ opt_limit_clause_init:
LEX *lex= Lex;
SELECT_LEX *sel= lex->current_select;
sel->offset_limit= 0L;
- sel->select_limit= (&lex->select_lex == sel) ?
- Lex->thd->variables.select_limit : /* primary SELECT */
- HA_POS_ERROR; /* subquery */
+ sel->select_limit= HA_POS_ERROR;
}
| limit_clause {}
;
@@ -3588,18 +3586,21 @@ limit_options:
SELECT_LEX *sel= Select;
sel->select_limit= $1;
sel->offset_limit= 0L;
+ sel->explicit_limit= 1;
}
| ULONG_NUM ',' ULONG_NUM
{
SELECT_LEX *sel= Select;
sel->select_limit= $3;
sel->offset_limit= $1;
+ sel->explicit_limit= 1;
}
| ULONG_NUM OFFSET_SYM ULONG_NUM
{
SELECT_LEX *sel= Select;
sel->select_limit= $1;
sel->offset_limit= $3;
+ sel->explicit_limit= 1;
}
;
@@ -3611,7 +3612,11 @@ delete_limit_clause:
lex->current_select->select_limit= HA_POS_ERROR;
}
| LIMIT ulonglong_num
- { Select->select_limit= (ha_rows) $2; };
+ {
+ SELECT_LEX *sel= Select;
+ sel->select_limit= (ha_rows) $2;
+ sel->explicit_limit= 1;
+ };
ULONG_NUM:
NUM { $$= strtoul($1.str,NULL,10); }