Commit ff13fc6d authored by mskold@mysql.com's avatar mskold@mysql.com

Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  mysql.com:/usr/local/home/marty/MySQL/mysql-5.1-new-wl1892
parents 267801e5 e84cf2c7
...@@ -3554,8 +3554,6 @@ drop procedure if exists bug7049_1| ...@@ -3554,8 +3554,6 @@ drop procedure if exists bug7049_1|
drop procedure if exists bug7049_2| drop procedure if exists bug7049_2|
drop procedure if exists bug7049_3| drop procedure if exists bug7049_3|
drop procedure if exists bug7049_4| drop procedure if exists bug7049_4|
drop procedure if exists bug7049_5|
drop procedure if exists bug7049_6|
drop function if exists bug7049_1| drop function if exists bug7049_1|
drop function if exists bug7049_2| drop function if exists bug7049_2|
create table t3 ( x int unique )| create table t3 ( x int unique )|
...@@ -3580,18 +3578,6 @@ select 'Caught it' as 'Result'; ...@@ -3580,18 +3578,6 @@ select 'Caught it' as 'Result';
call bug7049_3(); call bug7049_3();
select 'Missed it' as 'Result'; select 'Missed it' as 'Result';
end| end|
create procedure bug7049_5()
begin
declare x decimal(2,1);
set x = 'zap';
end|
create procedure bug7049_6()
begin
declare exit handler for sqlwarning
select 'Caught it' as 'Result';
call bug7049_5();
select 'Missed it' as 'Result';
end|
create function bug7049_1() create function bug7049_1()
returns int returns int
begin begin
...@@ -3621,9 +3607,6 @@ Caught it ...@@ -3621,9 +3607,6 @@ Caught it
select * from t3| select * from t3|
x x
42 42
call bug7049_6()|
Result
Caught it
select bug7049_2()| select bug7049_2()|
bug7049_2() bug7049_2()
1 1
...@@ -3632,8 +3615,6 @@ drop procedure bug7049_1| ...@@ -3632,8 +3615,6 @@ drop procedure bug7049_1|
drop procedure bug7049_2| drop procedure bug7049_2|
drop procedure bug7049_3| drop procedure bug7049_3|
drop procedure bug7049_4| drop procedure bug7049_4|
drop procedure bug7049_5|
drop procedure bug7049_6|
drop function bug7049_1| drop function bug7049_1|
drop function bug7049_2| drop function bug7049_2|
drop function if exists bug13941| drop function if exists bug13941|
...@@ -4315,4 +4296,59 @@ id county ...@@ -4315,4 +4296,59 @@ id county
2 NULL 2 NULL
drop table t3| drop table t3|
drop procedure bug15441| drop procedure bug15441|
drop table if exists t3|
drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
create table t3 (id int not null)|
create procedure bug15231_1()
begin
declare xid integer;
declare xdone integer default 0;
declare continue handler for not found set xdone = 1;
set xid=null;
call bug15231_2(xid);
select xid, xdone;
end|
create procedure bug15231_2(inout ioid integer)
begin
select "Before NOT FOUND condition is triggered" as '1';
select id into ioid from t3 where id=ioid;
select "After NOT FOUND condtition is triggered" as '2';
if ioid is null then
set ioid=1;
end if;
end|
create procedure bug15231_3()
begin
declare exit handler for sqlwarning
select 'Caught it (wrong)' as 'Result';
call bug15231_4();
end|
create procedure bug15231_4()
begin
declare x decimal(2,1);
set x = 'zap';
select 'Missed it (correct)' as 'Result';
end|
call bug15231_1()|
1
Before NOT FOUND condition is triggered
2
After NOT FOUND condtition is triggered
xid xdone
1 0
Warnings:
Warning 1329 No data to FETCH
call bug15231_3()|
Result
Missed it (correct)
Warnings:
Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1
drop table if exists t3|
drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
drop table t1,t2; drop table t1,t2;
...@@ -4297,8 +4297,6 @@ drop procedure if exists bug7049_1| ...@@ -4297,8 +4297,6 @@ drop procedure if exists bug7049_1|
drop procedure if exists bug7049_2| drop procedure if exists bug7049_2|
drop procedure if exists bug7049_3| drop procedure if exists bug7049_3|
drop procedure if exists bug7049_4| drop procedure if exists bug7049_4|
drop procedure if exists bug7049_5|
drop procedure if exists bug7049_6|
drop function if exists bug7049_1| drop function if exists bug7049_1|
drop function if exists bug7049_2| drop function if exists bug7049_2|
--enable_warnings --enable_warnings
...@@ -4332,22 +4330,6 @@ begin ...@@ -4332,22 +4330,6 @@ begin
select 'Missed it' as 'Result'; select 'Missed it' as 'Result';
end| end|
create procedure bug7049_5()
begin
declare x decimal(2,1);
set x = 'zap';
end|
create procedure bug7049_6()
begin
declare exit handler for sqlwarning
select 'Caught it' as 'Result';
call bug7049_5();
select 'Missed it' as 'Result';
end|
create function bug7049_1() create function bug7049_1()
returns int returns int
begin begin
...@@ -4372,7 +4354,6 @@ select * from t3| ...@@ -4372,7 +4354,6 @@ select * from t3|
delete from t3| delete from t3|
call bug7049_4()| call bug7049_4()|
select * from t3| select * from t3|
call bug7049_6()|
select bug7049_2()| select bug7049_2()|
drop table t3| drop table t3|
...@@ -4380,8 +4361,6 @@ drop procedure bug7049_1| ...@@ -4380,8 +4361,6 @@ drop procedure bug7049_1|
drop procedure bug7049_2| drop procedure bug7049_2|
drop procedure bug7049_3| drop procedure bug7049_3|
drop procedure bug7049_4| drop procedure bug7049_4|
drop procedure bug7049_5|
drop procedure bug7049_6|
drop function bug7049_1| drop function bug7049_1|
drop function bug7049_2| drop function bug7049_2|
...@@ -5069,6 +5048,68 @@ call bug15441('Yale')| ...@@ -5069,6 +5048,68 @@ call bug15441('Yale')|
drop table t3| drop table t3|
drop procedure bug15441| drop procedure bug15441|
#
# BUG#15231: Stored procedure bug with not found condition handler
#
--disable_warnings
drop table if exists t3|
drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
--enable_warnings
create table t3 (id int not null)|
create procedure bug15231_1()
begin
declare xid integer;
declare xdone integer default 0;
declare continue handler for not found set xdone = 1;
set xid=null;
call bug15231_2(xid);
select xid, xdone;
end|
create procedure bug15231_2(inout ioid integer)
begin
select "Before NOT FOUND condition is triggered" as '1';
select id into ioid from t3 where id=ioid;
select "After NOT FOUND condtition is triggered" as '2';
if ioid is null then
set ioid=1;
end if;
end|
create procedure bug15231_3()
begin
declare exit handler for sqlwarning
select 'Caught it (wrong)' as 'Result';
call bug15231_4();
end|
create procedure bug15231_4()
begin
declare x decimal(2,1);
set x = 'zap';
select 'Missed it (correct)' as 'Result';
end|
call bug15231_1()|
call bug15231_3()|
drop table if exists t3|
drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -160,6 +160,10 @@ sp_rcontext::set_return_value(THD *thd, Item *return_value_item) ...@@ -160,6 +160,10 @@ sp_rcontext::set_return_value(THD *thd, Item *return_value_item)
} }
#define IS_WARNING_CONDITION(S) ((S)[0] == '0' && (S)[1] == '1')
#define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2')
#define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2')
bool bool
sp_rcontext::find_handler(uint sql_errno, sp_rcontext::find_handler(uint sql_errno,
MYSQL_ERROR::enum_warning_level level) MYSQL_ERROR::enum_warning_level level)
...@@ -193,18 +197,17 @@ sp_rcontext::find_handler(uint sql_errno, ...@@ -193,18 +197,17 @@ sp_rcontext::find_handler(uint sql_errno,
found= i; found= i;
break; break;
case sp_cond_type_t::warning: case sp_cond_type_t::warning:
if ((sqlstate[0] == '0' && sqlstate[1] == '1' || if ((IS_WARNING_CONDITION(sqlstate) ||
level == MYSQL_ERROR::WARN_LEVEL_WARN) && level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
found < 0) found < 0)
found= i; found= i;
break; break;
case sp_cond_type_t::notfound: case sp_cond_type_t::notfound:
if (sqlstate[0] == '0' && sqlstate[1] == '2' && if (IS_NOT_FOUND_CONDITION(sqlstate) && found < 0)
found < 0)
found= i; found= i;
break; break;
case sp_cond_type_t::exception: case sp_cond_type_t::exception:
if ((sqlstate[0] != '0' || sqlstate[1] > '2') && if (IS_EXCEPTION_CONDITION(sqlstate) &&
level == MYSQL_ERROR::WARN_LEVEL_ERROR && level == MYSQL_ERROR::WARN_LEVEL_ERROR &&
found < 0) found < 0)
found= i; found= i;
...@@ -213,7 +216,13 @@ sp_rcontext::find_handler(uint sql_errno, ...@@ -213,7 +216,13 @@ sp_rcontext::find_handler(uint sql_errno,
} }
if (found < 0) if (found < 0)
{ {
if (m_prev_runtime_ctx) /*
Only "exception conditions" are propagated to handlers in calling
contexts. If no handler is found locally for a "completion condition"
(warning or "not found") we will simply resume execution.
*/
if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) &&
level == MYSQL_ERROR::WARN_LEVEL_ERROR)
return m_prev_runtime_ctx->find_handler(sql_errno, level); return m_prev_runtime_ctx->find_handler(sql_errno, level);
return FALSE; return FALSE;
} }
......
...@@ -158,6 +158,7 @@ NdbBlob::getBlobEventName(char* bename, Ndb* anNdb, const char* eventName, const ...@@ -158,6 +158,7 @@ NdbBlob::getBlobEventName(char* bename, Ndb* anNdb, const char* eventName, const
if (c == NULL) if (c == NULL)
return -1; return -1;
getBlobEventName(bename, e, c); getBlobEventName(bename, e, c);
delete e; // it is from new NdbEventImpl
return 0; return 0;
} }
......
...@@ -161,7 +161,8 @@ NdbEventOperationImpl::~NdbEventOperationImpl() ...@@ -161,7 +161,8 @@ NdbEventOperationImpl::~NdbEventOperationImpl()
; // ToDo? We should send stop signal here ; // ToDo? We should send stop signal here
m_ndb->theImpl->theNdbObjectIdMap.unmap(m_oid, this); m_ndb->theImpl->theNdbObjectIdMap.unmap(m_oid, this);
DBUG_PRINT("exit",("this: 0x%x/0x%x oid: %u", this, m_facade, m_oid)); DBUG_PRINT("exit",("this: %p/%p oid: %u main: %p",
this, m_facade, m_oid, theMainOp));
if (m_eventImpl) if (m_eventImpl)
{ {
...@@ -2098,6 +2099,14 @@ NdbEventBuffer::dropEventOperation(NdbEventOperation* tOp) ...@@ -2098,6 +2099,14 @@ NdbEventBuffer::dropEventOperation(NdbEventOperation* tOp)
tBlobOp->stop(); tBlobOp->stop();
tBlobOp = tBlobOp->m_next; tBlobOp = tBlobOp->m_next;
} }
// release blob handles now, further access is user error
while (op->theBlobList != NULL)
{
NdbBlob* tBlob = op->theBlobList;
op->theBlobList = tBlob->theNext;
m_ndb->releaseNdbBlob(tBlob);
}
} }
// ToDo, take care of these to be deleted at the // ToDo, take care of these to be deleted at the
......
...@@ -366,11 +366,12 @@ struct Data { ...@@ -366,11 +366,12 @@ struct Data {
noop = 0; noop = 0;
ppeq = 0; ppeq = 0;
} }
void free() { void freemem() {
delete [] tx1.val; delete [] tx1.val;
delete [] tx2.val; delete [] tx2.val;
delete [] bl1.val; delete [] bl1.val;
init(); tx1.val = tx2.val = bl1.val = 0;
tx1.len = tx2.len = bl1.len = 0;
} }
}; };
...@@ -469,6 +470,12 @@ operator<<(NdbOut& out, const Data& d) ...@@ -469,6 +470,12 @@ operator<<(NdbOut& out, const Data& d)
return out; return out;
} }
// some random os may define these
#undef NUL
#undef INS
#undef DEL
#undef UPD
static const uint g_optypes = 3; // real ops 0-2 static const uint g_optypes = 3; // real ops 0-2
/* /*
...@@ -504,6 +511,10 @@ struct Op { // single or composite ...@@ -504,6 +511,10 @@ struct Op { // single or composite
match = false; match = false;
gci = 0; gci = 0;
} }
void freemem() {
data[0].freemem();
data[1].freemem();
}
}; };
static NdbOut& static NdbOut&
...@@ -583,7 +594,7 @@ getop(Op::Kind a_kind) ...@@ -583,7 +594,7 @@ getop(Op::Kind a_kind)
assert(g_freeops == 0); assert(g_freeops == 0);
Op* op = new Op; Op* op = new Op;
assert(op != 0); assert(op != 0);
op->next_free = g_opfree; op->next_free = g_opfree; // 0
g_opfree = op; g_opfree = op;
op->free = true; op->free = true;
g_freeops++; g_freeops++;
...@@ -594,6 +605,7 @@ getop(Op::Kind a_kind) ...@@ -594,6 +605,7 @@ getop(Op::Kind a_kind)
g_freeops--; g_freeops--;
g_usedops++; g_usedops++;
op->init(a_kind); op->init(a_kind);
op->free = false;
return op; return op;
} }
...@@ -601,8 +613,7 @@ static void ...@@ -601,8 +613,7 @@ static void
freeop(Op* op) freeop(Op* op)
{ {
assert(! op->free); assert(! op->free);
op->data[0].free(); op->freemem();
op->data[1].free();
op->free = true; op->free = true;
op->next_free = g_opfree; op->next_free = g_opfree;
g_opfree = op; g_opfree = op;
...@@ -665,6 +676,18 @@ resetmem() ...@@ -665,6 +676,18 @@ resetmem()
g_num_gci = g_num_ev = 0; g_num_gci = g_num_ev = 0;
} }
static void
deleteops() // for memleak checks
{
while (g_opfree != 0) {
Op* tmp_op = g_opfree;
g_opfree = g_opfree->next_free;
delete tmp_op;
g_freeops--;
}
assert(g_freeops == 0);
}
struct Comp { struct Comp {
Op::Type t1, t2, t3; Op::Type t1, t2, t3;
}; };
...@@ -1312,6 +1335,10 @@ runops() ...@@ -1312,6 +1335,10 @@ runops()
Op* tot_op = g_pk_op[pk1]; Op* tot_op = g_pk_op[pk1];
if (tot_op == 0) if (tot_op == 0)
continue; continue;
if (tot_op->next_gci == 0) {
assert(g_loop != 0 && tot_op->type == Op::INS);
continue;
}
// first commit chain // first commit chain
assert(tot_op->next_gci != 0); assert(tot_op->next_gci != 0);
gci_op[pk1] = tot_op->next_gci; gci_op[pk1] = tot_op->next_gci;
...@@ -1361,7 +1388,10 @@ mergeops() ...@@ -1361,7 +1388,10 @@ mergeops()
if (tot_op == 0) if (tot_op == 0)
continue; continue;
Op* gci_op = tot_op->next_gci; Op* gci_op = tot_op->next_gci;
assert(gci_op != 0); if (gci_op == 0) {
assert(g_loop != 0 && tot_op->type == Op::INS);
continue;
}
while (gci_op != 0) { while (gci_op != 0) {
Op* com_op = gci_op->next_com; Op* com_op = gci_op->next_com;
assert(com_op != 0 && com_op->next_com == 0); assert(com_op != 0 && com_op->next_com == 0);
...@@ -1648,6 +1678,7 @@ runevents() ...@@ -1648,6 +1678,7 @@ runevents()
// copy and add // copy and add
Op* ev = getop(Op::EV); Op* ev = getop(Op::EV);
copyop(g_rec_ev, ev); copyop(g_rec_ev, ev);
g_rec_ev->freemem();
last_ev->next_ev = ev; last_ev->next_ev = ev;
g_num_ev++; g_num_ev++;
} }
...@@ -1706,6 +1737,8 @@ runtest() ...@@ -1706,6 +1737,8 @@ runtest()
} }
chkrc(dropevent() == 0); chkrc(dropevent() == 0);
chkrc(droptable() == 0); chkrc(droptable() == 0);
resetmem();
deleteops();
return 0; return 0;
} }
...@@ -1836,8 +1869,11 @@ main(int argc, char** argv) ...@@ -1836,8 +1869,11 @@ main(int argc, char** argv)
if (g_ncc->connect(30) == 0) { if (g_ncc->connect(30) == 0) {
g_ndb = new Ndb(g_ncc, "TEST_DB"); g_ndb = new Ndb(g_ncc, "TEST_DB");
if (g_ndb->init() == 0 && g_ndb->waitUntilReady(30) == 0) { if (g_ndb->init() == 0 && g_ndb->waitUntilReady(30) == 0) {
if (runtest() == 0) if (runtest() == 0) {
delete g_ndb;
delete g_ncc;
return NDBT_ProgramExit(NDBT_OK); return NDBT_ProgramExit(NDBT_OK);
}
} }
} }
if (g_evt_op != 0) { if (g_evt_op != 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