summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-11-01 15:54:30 +0200
committerunknown <monty@mysql.com>2005-11-01 15:54:30 +0200
commitee380a077782f87d80aae7a8c9c9ead51dfd8e7b (patch)
treea19fa82d4c5fc0f845231b5d75a45a0c36e0494d
parentf9dbcd558a52652692c4593c93656431e4cbf043 (diff)
downloadmariadb-git-ee380a077782f87d80aae7a8c9c9ead51dfd8e7b.tar.gz
Reverting patch for BUG #14009 (use of abs() on null value causes problems with filesort
Fix for bug #14536: SELECT @a,@a:=... fails with prepared statements mysql-test/r/func_sapdb.result: Correct tests after reverting patch for BUG #14009 (use of abs() on null value causes problems with filesort) mysql-test/r/type_newdecimal.result: Correct tests after reverting patch for BUG #14009 (use of abs() on null value causes problems with filesort) mysql-test/r/user_var.result: More test with SELECT @a:= mysql-test/t/disabled.def: Enable user_var.test for mysql-test/t/user_var.test: More test with SELECT @a:= sql/item.cc: Simple optimization during review of new code sql/item_func.cc: Reverting patch for BUG #14009 (use of abs() on null value causes problems with filesort) sql/item_timefunc.h: timediff() can return NULL for not NULL arguments sql/sql_base.cc: Remove usage of current_thd() in mysql_make_view() sql/sql_lex.h: Remove usage of current_thd() in mysql_make_view() sql/sql_select.cc: Fix for bug #14536: SELECT @a,@a:=... fails with prepared statements sql/sql_view.cc: Remove usage of current_thd() in mysql_make_view() Simple optimization of new code sql/sql_view.h: Remove usage of current_thd() in mysql_make_view() sql/table.cc: Simple optimization of new code
-rw-r--r--mysql-test/r/func_sapdb.result4
-rw-r--r--mysql-test/r/type_newdecimal.result2
-rw-r--r--mysql-test/r/user_var.result11
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--mysql-test/t/user_var.test4
-rw-r--r--sql/item.cc12
-rw-r--r--sql/item_func.cc1
-rw-r--r--sql/item_timefunc.h1
-rw-r--r--sql/sql_base.cc19
-rw-r--r--sql/sql_lex.h4
-rw-r--r--sql/sql_select.cc11
-rw-r--r--sql/sql_view.cc42
-rw-r--r--sql/sql_view.h2
-rw-r--r--sql/table.cc9
14 files changed, 70 insertions, 53 deletions
diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result
index f209866d953..d984eee80fa 100644
--- a/mysql-test/r/func_sapdb.result
+++ b/mysql-test/r/func_sapdb.result
@@ -180,8 +180,8 @@ Field Type Null Key Default Extra
f1 date NO 0000-00-00
f2 datetime YES NULL
f3 time YES NULL
-f4 time NO 00:00:00
-f5 time NO 00:00:00
+f4 time YES NULL
+f5 time YES NULL
f6 time NO 00:00:00
f7 datetime YES NULL
f8 date YES NULL
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 45eb8aab89e..dbae646c362 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -176,7 +176,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`round(15.4,-1)` decimal(3,0) unsigned NOT NULL default '0',
`truncate(-5678.123451,-3)` decimal(4,0) NOT NULL default '0',
- `abs(-1.1)` decimal(2,1) default NULL,
+ `abs(-1.1)` decimal(2,1) NOT NULL default '0.0',
`-(-1.1)` decimal(2,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index acdc793fb69..75a680e504d 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -123,6 +123,17 @@ select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
0 1 1 0
1 3 2 0
3 6 3 0
+set @a=0;
+select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i;
+@a @a:="hello" @a @a:=3 @a @a:="hello again"
+0 hello 0 3 0 hello again
+0 hello 0 3 0 hello again
+0 hello 0 3 0 hello again
+select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i;
+@a @a:="hello" @a @a:=3 @a @a:="hello again"
+hello again hello hello again 3 hello again hello again
+hello again hello hello again 3 hello again hello again
+hello again hello hello again 3 hello again hello again
drop table t1;
set @a=_latin2'test';
select charset(@a),collation(@a),coercibility(@a);
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 8e3dfa55847..eedf4b30e73 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -16,4 +16,3 @@ rpl_until : Unstable test case, bug#12429
rpl_deadlock : Unstable test case, bug#12429
kill : Unstable test case, bug#9712
archive_gis : The test fails on 32bit Linux
-user_var : Ramil should fix this soon
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index e3b5b4ef33e..61861c26ea8 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -70,6 +70,10 @@ create table t1 (i int not null);
insert t1 values (1),(2),(2),(3),(3),(3);
select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
+
+set @a=0;
+select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i;
+select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i;
drop table t1;
#
diff --git a/sql/item.cc b/sql/item.cc
index 51fb2fe34fd..1850b7d05c3 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5082,14 +5082,16 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
{
DBUG_ASSERT(fixed == 0);
/* We should only check that arg is in first table */
- st_table_list *orig_next_table= context->last_name_resolution_table;
- context->last_name_resolution_table= context->first_name_resolution_table;
- if (!arg->fixed && arg->fix_fields(thd, &arg))
+ if (!arg->fixed)
{
+ bool res;
+ st_table_list *orig_next_table= context->last_name_resolution_table;
+ context->last_name_resolution_table= context->first_name_resolution_table;
+ res= arg->fix_fields(thd, &arg);
context->last_name_resolution_table= orig_next_table;
- return TRUE;
+ if (res)
+ return TRUE;
}
- context->last_name_resolution_table= orig_next_table;
if (arg->type() == REF_ITEM)
{
diff --git a/sql/item_func.cc b/sql/item_func.cc
index df25c3c97fa..9c1d1f63635 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -636,7 +636,6 @@ void Item_func_num1::fix_num_length_and_dec()
{
decimals= args[0]->decimals;
max_length= args[0]->max_length;
- maybe_null= 1;
}
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 196966f5388..b2352e728c5 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -845,6 +845,7 @@ public:
{
decimals=0;
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+ maybe_null= 1;
}
Field *tmp_table_field(TABLE *t_arg)
{
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 2da0f7e2ce0..6651a638931 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -37,11 +37,11 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
TABLE_LIST *table_list, MEM_ROOT *mem_root);
static void free_cache_entry(TABLE *entry);
static void mysql_rm_tmp_tables(void);
-static my_bool open_new_frm(const char *path, const char *alias,
- const char *db, const char *table_name,
- uint db_stat, uint prgflag,
- uint ha_open_flags, TABLE *outparam,
- TABLE_LIST *table_desc, MEM_ROOT *mem_root);
+static bool open_new_frm(THD *thd, const char *path, const char *alias,
+ const char *db, const char *table_name,
+ uint db_stat, uint prgflag,
+ uint ha_open_flags, TABLE *outparam,
+ TABLE_LIST *table_desc, MEM_ROOT *mem_root);
extern "C" byte *table_cache_key(const byte *record,uint *length,
my_bool not_used __attribute__((unused)))
@@ -1755,7 +1755,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
thd->open_options, entry)) &&
(error != 5 ||
(fn_format(path, path, 0, reg_ext, MY_UNPACK_FILENAME),
- open_new_frm(path, alias, db, name,
+ open_new_frm(thd, path, alias, db, name,
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
HA_GET_INDEX | HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
@@ -5260,6 +5260,7 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
SYNOPSIS
open_new_frm()
+ THD thread handler
path path to .frm
alias alias for table
db database
@@ -5273,8 +5274,8 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
mem_root temporary MEM_ROOT for parsing
*/
-static my_bool
-open_new_frm(const char *path, const char *alias,
+static bool
+open_new_frm(THD *thd, const char *path, const char *alias,
const char *db, const char *table_name,
uint db_stat, uint prgflag,
uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc,
@@ -5296,7 +5297,7 @@ open_new_frm(const char *path, const char *alias,
my_error(ER_WRONG_OBJECT, MYF(0), db, table_name, "BASE TABLE");
goto err;
}
- if (mysql_make_view(parser, table_desc))
+ if (mysql_make_view(thd, parser, table_desc))
goto err;
}
else
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 132a0491968..a8bee9bb59b 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -361,8 +361,8 @@ public:
friend class st_select_lex_unit;
friend bool mysql_new_select(struct st_lex *lex, bool move_down);
- friend my_bool mysql_make_view (File_parser *parser,
- TABLE_LIST *table);
+ friend bool mysql_make_view(THD *thd, File_parser *parser,
+ TABLE_LIST *table);
private:
void fast_exclude();
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index af2e5879b95..61dc7772984 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1237,7 +1237,8 @@ JOIN::exec()
if (zero_result_cause)
{
- (void) return_zero_rows(this, result, select_lex->leaf_tables, *columns_list,
+ (void) return_zero_rows(this, result, select_lex->leaf_tables,
+ *columns_list,
send_row_on_empty_set(),
select_options,
zero_result_cause,
@@ -1671,7 +1672,8 @@ JOIN::exec()
{
thd->proc_info="Sending data";
DBUG_PRINT("info", ("%s", thd->proc_info));
- result->send_fields(*columns_list,
+ result->send_fields((procedure ? curr_join->procedure_fields_list :
+ *curr_fields_list),
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
error= do_select(curr_join, curr_fields_list, NULL, procedure);
thd->limit_found_rows= curr_join->send_records;
@@ -9023,7 +9025,6 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
int rc= 0;
enum_nested_loop_state error= NESTED_LOOP_OK;
JOIN_TAB *join_tab;
- List<Item> *columns_list= procedure? &join->procedure_fields_list : fields;
DBUG_ENTER("do_select");
join->procedure=procedure;
@@ -9057,7 +9058,11 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
error= (*end_select)(join,join_tab,1);
}
else if (join->send_row_on_empty_set())
+ {
+ List<Item> *columns_list= (procedure ? &join->procedure_fields_list :
+ fields);
rc= join->result->send_data(*columns_list);
+ }
}
else
{
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index b30f8cb156c..846130c53fc 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -728,20 +728,24 @@ loop_out:
SYNOPSIS
mysql_make_view()
- parser - parser object;
- table - TABLE_LIST structure for filling
+ thd Thread handler
+ parser parser object
+ table TABLE_LIST structure for filling
RETURN
0 ok
1 error
*/
-my_bool
-mysql_make_view(File_parser *parser, TABLE_LIST *table)
+bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table)
{
- THD *thd= current_thd;
+ SELECT_LEX *end, *view_select;
+ LEX *old_lex, *lex;
+ Query_arena *arena, backup;
+ int res;
+ bool result;
DBUG_ENTER("mysql_make_view");
- DBUG_PRINT("info", ("table=%p (%s)", table, table->table_name));
+ DBUG_PRINT("info", ("table: 0x%lx (%s)", (ulong) table, table->table_name));
if (table->view)
{
@@ -765,16 +769,12 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
DBUG_RETURN(0);
}
- SELECT_LEX *end;
- LEX *old_lex= thd->lex, *lex;
- SELECT_LEX *view_select;
- int res= 0;
-
/*
For now we assume that tables will not be changed during PS life (it
will be TRUE as far as we make new table cache).
*/
- Query_arena *arena= thd->stmt_arena, backup;
+ old_lex= thd->lex;
+ arena= thd->stmt_arena;
if (arena->is_conventional())
arena= 0;
else
@@ -1133,23 +1133,21 @@ ok:
(st_select_lex_node**)&old_lex->all_selects_list;
ok2:
- if (arena)
- thd->restore_active_arena(arena, &backup);
if (!old_lex->time_zone_tables_used && thd->lex->time_zone_tables_used)
old_lex->time_zone_tables_used= thd->lex->time_zone_tables_used;
- thd->lex= old_lex;
- if (!table->prelocking_placeholder && table->prepare_security(thd))
- DBUG_RETURN(1);
-
- DBUG_RETURN(0);
+ result= !table->prelocking_placeholder && table->prepare_security(thd);
-err:
+end:
if (arena)
thd->restore_active_arena(arena, &backup);
+ thd->lex= old_lex;
+ DBUG_RETURN(result);
+
+err:
delete table->view;
table->view= 0; // now it is not VIEW placeholder
- thd->lex= old_lex;
- DBUG_RETURN(1);
+ result= 1;
+ goto end;
}
diff --git a/sql/sql_view.h b/sql/sql_view.h
index 4cc9eb454fb..f58fe1fc6ca 100644
--- a/sql/sql_view.h
+++ b/sql/sql_view.h
@@ -19,7 +19,7 @@
bool mysql_create_view(THD *thd,
enum_view_create_mode mode);
-my_bool mysql_make_view(File_parser *parser, TABLE_LIST *table);
+bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table);
bool mysql_drop_view(THD *thd, TABLE_LIST *view, enum_drop_mode drop_mode);
diff --git a/sql/table.cc b/sql/table.cc
index 75c04389411..a18ff4397d1 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2654,7 +2654,7 @@ Natural_join_column::check_grants(THD *thd, const char *name, uint length)
GRANT_INFO *grant;
const char *db_name;
const char *table_name;
- Security_context *save_security_ctx= 0;
+ Security_context *save_security_ctx;
Security_context *new_sctx= table_ref->security_ctx;
bool res;
@@ -2673,14 +2673,11 @@ Natural_join_column::check_grants(THD *thd, const char *name, uint length)
table_name= table_ref->table->s->table_name;
}
+ save_security_ctx= thd->security_ctx;
if (new_sctx)
- {
- save_security_ctx= thd->security_ctx;
thd->security_ctx= new_sctx;
- }
res= check_grant_column(thd, grant, db_name, table_name, name, length);
- if (save_security_ctx)
- thd->security_ctx= save_security_ctx;
+ thd->security_ctx= save_security_ctx;
return res;
}
#endif