Commit a009a3dc authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  neptunus.(none):/home/msvensson/mysql/bug10713_new/my50-bug10713_new


mysql-test/r/view.result:
  Auto merged
mysql-test/t/mysqldump.test:
  Auto merged
parents 2761c648 20c8bfe7
...@@ -3225,4 +3225,43 @@ select @var| ...@@ -3225,4 +3225,43 @@ select @var|
@var @var
abcdabcd abcdabcd
drop procedure bug12849_2| drop procedure bug12849_2|
drop procedure if exists bug131333|
drop function if exists bug131333|
create procedure bug131333()
begin
begin
declare a int;
select a;
set a = 1;
select a;
end;
begin
declare b int;
select b;
end;
end|
create function bug131333()
returns int
begin
begin
declare a int;
set a = 1;
end;
begin
declare b int;
return b;
end;
end|
call bug131333()|
a
NULL
a
1
b
NULL
select bug131333()|
bug131333()
NULL
drop procedure bug131333|
drop function bug131333|
drop table t1,t2; drop table t1,t2;
...@@ -1146,11 +1146,11 @@ create view v2 as select * from v1; ...@@ -1146,11 +1146,11 @@ create view v2 as select * from v1;
alter view v1 as select * from v2; alter view v1 as select * from v2;
ERROR 42S02: Table 'test.v1' doesn't exist ERROR 42S02: Table 'test.v1' doesn't exist
alter view v1 as select * from v1; alter view v1 as select * from v1;
ERROR 42000: Not unique table/alias: 'v1' ERROR 42S02: Table 'test.v1' doesn't exist
create or replace view v1 as select * from v2; create or replace view v1 as select * from v2;
ERROR 42S02: Table 'test.v1' doesn't exist ERROR 42S02: Table 'test.v1' doesn't exist
create or replace view v1 as select * from v1; create or replace view v1 as select * from v1;
ERROR 42000: Not unique table/alias: 'v1' ERROR 42S02: Table 'test.v1' doesn't exist
drop view v2,v1; drop view v2,v1;
drop table t1; drop table t1;
create table t1 (a int); create table t1 (a int);
...@@ -2186,3 +2186,7 @@ r_object_id users_names ...@@ -2186,3 +2186,7 @@ r_object_id users_names
120001a080000542 guser02 120001a080000542 guser02
drop view v1, v2; drop view v1, v2;
drop table t1, t2; drop table t1, t2;
create table t1 (s1 int);
create view abc as select * from t1 as abc;
drop table t1;
drop view abc;
...@@ -826,10 +826,10 @@ DROP TABLE t1, t2; ...@@ -826,10 +826,10 @@ DROP TABLE t1, t2;
# Bugs #9136, #12917: problems with --defaults-extra-file option # Bugs #9136, #12917: problems with --defaults-extra-file option
# #
--exec echo "[client]" > $MYSQL_TEST_DIR/var/tmp/tmp.cnf --exec echo "[mysqltest1]" > $MYSQL_TEST_DIR/var/tmp/tmp.cnf
--exec echo "port=1234" >> $MYSQL_TEST_DIR/var/tmp/tmp.cnf --exec echo "port=1234" >> $MYSQL_TEST_DIR/var/tmp/tmp.cnf
--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQL_TEST_DIR/var/tmp/tmp.cnf client --exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQL_TEST_DIR/var/tmp/tmp.cnf mysqltest1
--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQL_TEST_DIR/var/tmp/tmp.cnf client --exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQL_TEST_DIR/var/tmp/tmp.cnf mysqltest1
--exec rm $MYSQL_TEST_DIR/var/tmp/tmp.cnf --exec rm $MYSQL_TEST_DIR/var/tmp/tmp.cnf
# #
......
...@@ -4063,6 +4063,51 @@ call bug12849_2(@var)| ...@@ -4063,6 +4063,51 @@ call bug12849_2(@var)|
select @var| select @var|
drop procedure bug12849_2| drop procedure bug12849_2|
#
# BUG#13133: Local variables in stored procedures are not initialized correctly.
#
--disable_warnings
drop procedure if exists bug131333|
drop function if exists bug131333|
--enable_warnings
create procedure bug131333()
begin
begin
declare a int;
select a;
set a = 1;
select a;
end;
begin
declare b int;
select b;
end;
end|
create function bug131333()
returns int
begin
begin
declare a int;
set a = 1;
end;
begin
declare b int;
return b;
end;
end|
call bug131333()|
select bug131333()|
drop procedure bug131333|
drop function bug131333|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -1083,11 +1083,11 @@ create view v1 as select * from t1; ...@@ -1083,11 +1083,11 @@ create view v1 as select * from t1;
create view v2 as select * from v1; create view v2 as select * from v1;
-- error 1146 -- error 1146
alter view v1 as select * from v2; alter view v1 as select * from v2;
-- error 1066 -- error 1146
alter view v1 as select * from v1; alter view v1 as select * from v1;
-- error 1146 -- error 1146
create or replace view v1 as select * from v2; create or replace view v1 as select * from v2;
-- error 1066 -- error 1146
create or replace view v1 as select * from v1; create or replace view v1 as select * from v1;
drop view v2,v1; drop view v2,v1;
drop table t1; drop table t1;
...@@ -2059,3 +2059,12 @@ order by users_names; ...@@ -2059,3 +2059,12 @@ order by users_names;
drop view v1, v2; drop view v1, v2;
drop table t1, t2; drop table t1, t2;
#
# Bug #6808 - Views: CREATE VIEW v ... FROM t AS v fails
#
create table t1 (s1 int);
create view abc as select * from t1 as abc;
drop table t1;
drop view abc;
...@@ -272,6 +272,9 @@ SignalSender::execNodeStatus(void* signalSender, ...@@ -272,6 +272,9 @@ SignalSender::execNodeStatus(void* signalSender,
NdbCondition_Signal(ss->m_cond); NdbCondition_Signal(ss->m_cond);
} }
#if __SUNPRO_CC != 0x560
template SimpleSignal* SignalSender::waitFor<WaitForNode>(unsigned, WaitForNode&); template SimpleSignal* SignalSender::waitFor<WaitForNode>(unsigned, WaitForNode&);
template SimpleSignal* SignalSender::waitFor<WaitForAny>(unsigned, WaitForAny&); template SimpleSignal* SignalSender::waitFor<WaitForAny>(unsigned, WaitForAny&);
#endif
template class Vector<SimpleSignal*>; template class Vector<SimpleSignal*>;
...@@ -1078,7 +1078,6 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp) ...@@ -1078,7 +1078,6 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
sp_rcontext *octx = thd->spcont; sp_rcontext *octx = thd->spcont;
sp_rcontext *nctx = NULL; sp_rcontext *nctx = NULL;
uint i; uint i;
Item_null *nit;
int ret= -1; // Assume error int ret= -1; // Assume error
if (argcount != params) if (argcount != params)
...@@ -1109,22 +1108,15 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp) ...@@ -1109,22 +1108,15 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
nctx->push_item(it); nctx->push_item(it);
} }
/* /*
The rest of the frame are local variables which are all IN. The rest of the frame are local variables which are all IN.
Default all variables to null (those with default clauses will Push NULLs to get the right size (and make the reuse mechanism work) -
be set by an set instruction). the will be initialized by set instructions in each frame.
*/ */
nit= NULL; // Re-use this, and only create if needed
for (; i < csize ; i++) for (; i < csize ; i++)
{ nctx->push_item(NULL);
if (! nit)
{
if (!(nit= new Item_null()))
DBUG_RETURN(-1);
}
nctx->push_item(nit);
}
thd->spcont= nctx; thd->spcont= nctx;
binlog_save_options= thd->options; binlog_save_options= thd->options;
...@@ -1321,23 +1313,14 @@ int sp_head::execute_procedure(THD *thd, List<Item> *args) ...@@ -1321,23 +1313,14 @@ int sp_head::execute_procedure(THD *thd, List<Item> *args)
close_thread_tables(thd, 0, 0); close_thread_tables(thd, 0, 0);
DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str)); DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str));
/* /*
The rest of the frame are local variables which are all IN. The rest of the frame are local variables which are all IN.
Default all variables to null (those with default clauses will Push NULLs to get the right size (and make the reuse mechanism work) -
be set by an set instruction). the will be initialized by set instructions in each frame.
*/ */
for (; i < csize ; i++) for (; i < csize ; i++)
{ nctx->push_item(NULL);
if (! nit)
{
if (!(nit= new Item_null()))
{
ret= -1;
break;
}
}
nctx->push_item(nit);
}
} }
thd->spcont= nctx; thd->spcont= nctx;
......
...@@ -184,7 +184,6 @@ sp_pcontext::push_pvar(LEX_STRING *name, enum enum_field_types type, ...@@ -184,7 +184,6 @@ sp_pcontext::push_pvar(LEX_STRING *name, enum enum_field_types type,
p->type= type; p->type= type;
p->mode= mode; p->mode= mode;
p->offset= current_pvars(); p->offset= current_pvars();
p->isset= (mode == sp_param_out ? FALSE : TRUE);
p->dflt= NULL; p->dflt= NULL;
insert_dynamic(&m_pvar, (gptr)&p); insert_dynamic(&m_pvar, (gptr)&p);
} }
......
...@@ -35,7 +35,6 @@ typedef struct sp_pvar ...@@ -35,7 +35,6 @@ typedef struct sp_pvar
enum enum_field_types type; enum enum_field_types type;
sp_param_mode_t mode; sp_param_mode_t mode;
uint offset; // Offset in current frame uint offset; // Offset in current frame
my_bool isset;
Item *dflt; Item *dflt;
} sp_pvar_t; } sp_pvar_t;
...@@ -147,15 +146,6 @@ class sp_pcontext : public Sql_alloc ...@@ -147,15 +146,6 @@ class sp_pcontext : public Sql_alloc
p->type= type; p->type= type;
} }
inline void
set_isset(uint i, my_bool val)
{
sp_pvar_t *p= find_pvar(i);
if (p)
p->isset= val;
}
inline void inline void
set_default(uint i, Item *it) set_default(uint i, Item *it)
{ {
......
...@@ -6056,7 +6056,10 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ...@@ -6056,7 +6056,10 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
/* check that used name is unique */ /* check that used name is unique */
if (lock_type != TL_IGNORE) if (lock_type != TL_IGNORE)
{ {
for (TABLE_LIST *tables=(TABLE_LIST*) table_list.first ; TABLE_LIST *first_table= (TABLE_LIST*) table_list.first;
if (lex->sql_command == SQLCOM_CREATE_VIEW)
first_table= first_table ? first_table->next_local : NULL;
for (TABLE_LIST *tables= first_table ;
tables ; tables ;
tables=tables->next_local) tables=tables->next_local)
{ {
......
...@@ -118,9 +118,18 @@ class Prepared_statement: public Statement ...@@ -118,9 +118,18 @@ class Prepared_statement: public Statement
bool deallocate(); bool deallocate();
/* Possible values of flags */ /* Possible values of flags */
#if defined(_MSC_VER) && _MSC_VER < 1300
static const int IS_IN_USE;
#else
static const int IS_IN_USE= 1; static const int IS_IN_USE= 1;
#endif
}; };
/* VC6 can't handle initializing in declaration */
#if defined(_MSC_VER) && _MSC_VER < 1300
const int Prepared_statement::IS_IN_USE= 1;
#endif
/****************************************************************************** /******************************************************************************
Implementation Implementation
******************************************************************************/ ******************************************************************************/
......
...@@ -1666,15 +1666,16 @@ sp_decl: ...@@ -1666,15 +1666,16 @@ sp_decl:
uint max= ctx->context_pvars(); uint max= ctx->context_pvars();
enum enum_field_types type= (enum enum_field_types)$3; enum enum_field_types type= (enum enum_field_types)$3;
Item *it= $5; Item *it= $5;
bool has_default= (it != NULL);
for (uint i = max-$2 ; i < max ; i++) for (uint i = max-$2 ; i < max ; i++)
{ {
sp_instr_set *in;
ctx->set_type(i, type); ctx->set_type(i, type);
if (! it) if (! has_default)
ctx->set_isset(i, FALSE); it= new Item_null(); /* QQ Set to the type with null_value? */
else in = new sp_instr_set(lex->sphead->instructions(),
{
sp_instr_set *in= new sp_instr_set(lex->sphead->instructions(),
ctx, ctx,
ctx->pvar_context2index(i), ctx->pvar_context2index(i),
it, type, lex, it, type, lex,
...@@ -1685,10 +1686,8 @@ sp_decl: ...@@ -1685,10 +1686,8 @@ sp_decl:
freeing LEX. freeing LEX.
*/ */
lex->sphead->add_instr(in); lex->sphead->add_instr(in);
ctx->set_isset(i, TRUE);
ctx->set_default(i, it); ctx->set_default(i, it);
} }
}
lex->sphead->restore_lex(YYTHD); lex->sphead->restore_lex(YYTHD);
$$.vars= $2; $$.vars= $2;
$$.conds= $$.hndlrs= $$.curs= 0; $$.conds= $$.hndlrs= $$.curs= 0;
...@@ -2268,7 +2267,6 @@ sp_fetch_list: ...@@ -2268,7 +2267,6 @@ sp_fetch_list:
sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction(); sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction();
i->add_to_varlist(spv); i->add_to_varlist(spv);
spv->isset= TRUE;
} }
} }
| |
...@@ -2290,7 +2288,6 @@ sp_fetch_list: ...@@ -2290,7 +2288,6 @@ sp_fetch_list:
sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction(); sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction();
i->add_to_varlist(spv); i->add_to_varlist(spv);
spv->isset= TRUE;
} }
} }
; ;
...@@ -5894,7 +5891,6 @@ select_var_ident: ...@@ -5894,7 +5891,6 @@ select_var_ident:
else else
{ {
((select_dumpvar *)lex->result)->var_list.push_back( new my_var($1,1,t->offset,t->type)); ((select_dumpvar *)lex->result)->var_list.push_back( new my_var($1,1,t->offset,t->type));
t->isset= TRUE;
} }
} }
; ;
...@@ -7925,7 +7921,6 @@ sys_option_value: ...@@ -7925,7 +7921,6 @@ sys_option_value:
sp_set= new sp_instr_set(lex->sphead->instructions(), ctx, sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
spv->offset, it, spv->type, lex, TRUE); spv->offset, it, spv->type, lex, TRUE);
lex->sphead->add_instr(sp_set); lex->sphead->add_instr(sp_set);
spv->isset= TRUE;
} }
} }
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
......
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