Commit 4e864685 authored by unknown's avatar unknown

Merge sinisa@work.mysql.com:/home/bk/mysql-4.1

into sinisa.nasamreza.org:/mnt/work/mysql-4.1


sql/sql_select.cc:
  Auto merged
parents 0fb3b8d9 a40a9d59
......@@ -40,3 +40,28 @@ a
select 1 from (select 1);
1
1
drop table if exists t1;
create table t1(a int not null, t char(8), index(a));
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
a t
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
drop table if exists t1;
......@@ -168,4 +168,14 @@ test2 2 2
SELECT FOUND_ROWS();
FOUND_ROWS()
2
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
1
SELECT FOUND_ROWS();
FOUND_ROWS()
1
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
titre numeropost maxnumrep
SELECT FOUND_ROWS();
FOUND_ROWS()
3
drop table t1;
......@@ -22,3 +22,15 @@ drop table if exists t1.t2,t3;
select * from (select 1);
select a from (select 1 as a);
select 1 from (select 1);
drop table if exists t1;
create table t1(a int not null, t char(8), index(a));
disable_query_log;
let $1 = 10000;
while ($1)
{
eval insert into t1 values ($1,'$1');
dec $1;
}
enable_query_log;
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
drop table if exists t1;
\ No newline at end of file
......@@ -84,4 +84,8 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
('test1','1'),('test2','2'),('test3','3');
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
SELECT FOUND_ROWS();
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
SELECT FOUND_ROWS();
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
SELECT FOUND_ROWS();
drop table t1;
......@@ -35,13 +35,13 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
SQL_SELECT *select=0;
READ_RECORD info;
bool using_limit=limit != HA_POS_ERROR;
bool using_transactions;
bool using_transactions, safe_update;
ha_rows deleted;
DBUG_ENTER("mysql_delete");
if (!table_list->db)
table_list->db=thd->db;
if ((thd->options & OPTION_SAFE_UPDATES) && !conds)
if (((safe_update=thd->options & OPTION_SAFE_UPDATES)) && !conds)
{
send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
DBUG_RETURN(1);
......@@ -58,7 +58,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
/* Test if the user wants to delete all rows */
if (!using_limit && (!conds || conds->const_item()) &&
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)))
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) && !safe_update)
{
deleted= table->file->records;
if (!(error=table->file->delete_all_rows()))
......@@ -79,9 +79,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
select=make_select(table,0,0,conds,&error);
if (error)
DBUG_RETURN(-1);
if ((select && select->check_quick(test(thd->options & OPTION_SAFE_UPDATES),
limit)) ||
!limit)
if ((select && select->check_quick(safe_update, limit)) || !limit)
{
delete select;
send_ok(thd,0L);
......@@ -92,7 +90,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
if (!table->quick_keys)
{
thd->lex.select_lex.options|=QUERY_NO_INDEX_USED;
if ((thd->options & OPTION_SAFE_UPDATES) && limit == HA_POS_ERROR)
if (safe_update && !using_limit)
{
delete select;
send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
......
......@@ -119,7 +119,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
table->tmp_table=TMP_TABLE;
if (!lex->describe)
sl->exclude();
t->db="";
t->db=(char *)"";
t->derived=(SELECT_LEX *)0; // just in case ...
}
}
......
......@@ -378,7 +378,7 @@ JOIN::optimize()
error = 0;
DBUG_RETURN(1);
}
if (cond_value == Item::COND_FALSE || !unit->select_limit_cnt)
if (cond_value == Item::COND_FALSE || (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */
zero_result_cause= "Impossible WHERE";
DBUG_RETURN(0);
......@@ -664,10 +664,13 @@ JOIN::exec()
result->send_fields(fields_list,1);
if (!having || having->val_int())
{
if (do_send_rows && result->send_data(fields_list))
if (do_send_rows && unit->select_limit_cnt && result->send_data(fields_list))
error= 1;
else
{
error= (int) result->send_eof();
send_records=1;
}
}
else
error=(int) result->send_eof();
......@@ -5181,7 +5184,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
error=0;
if (join->procedure)
error=join->procedure->send_row(*join->fields);
else if (join->do_send_rows)
else if (join->do_send_rows && join->unit->select_limit_cnt)
error=join->result->send_data(*join->fields);
if (error)
DBUG_RETURN(-1); /* purecov: inspected */
......
......@@ -523,7 +523,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
key_iterator.rewind();
key_number=0;
for (; (key=key_iterator++) ; key_info++, key_number++)
for (; (key=key_iterator++) ; key_number++)
{
uint key_length=0;
key_part_spec *column;
......@@ -734,6 +734,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
DBUG_RETURN(-1);
}
key_info++;
}
if (!unique_key && !primary_key &&
(file->table_flags() & HA_REQUIRE_PRIMARY_KEY))
......
......@@ -86,6 +86,7 @@ bool select_union::send_data(List<Item> &values)
}
else
return 1;
thd->net.report_error=0; // donno why does it work, but it does ...
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment