Commit 0b927000 authored by unknown's avatar unknown

Merge april.(none):/home/svoj/devel/mysql/BUG14496/mysql-4.1

into  april.(none):/home/svoj/devel/mysql/merge/mysql-4.1

parents e3c30863 8deb6616
...@@ -4628,6 +4628,12 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) ...@@ -4628,6 +4628,12 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
/* If statement hasnt been prepared there is nothing to reset */ /* If statement hasnt been prepared there is nothing to reset */
if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE) if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE)
DBUG_RETURN(0); DBUG_RETURN(0);
if (!stmt->mysql)
{
/* mysql can be reset in mysql_close called from mysql_reconnect */
set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate);
DBUG_RETURN(1);
}
mysql= stmt->mysql->last_used_con; mysql= stmt->mysql->last_used_con;
int4store(buff, stmt->stmt_id); /* Send stmt id to server */ int4store(buff, stmt->stmt_id); /* Send stmt id to server */
......
...@@ -428,6 +428,13 @@ delete from t1; ...@@ -428,6 +428,13 @@ delete from t1;
select * from t1; select * from t1;
a b a b
commit; commit;
replace t1 set a=2, b='y';
select * from t1;
a b
2 y
delete from t1;
select * from t1;
a b
drop table t1; drop table t1;
set autocommit=0; set autocommit=0;
create table t1 ( create table t1 (
......
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
ERROR 23000: Can't write; duplicate key in table 't1'
DROP TABLE t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
word
Aarhus
Aarhus
Aaron
Aaron
Ababa
Ababa
aback
aback
abaft
abaft
abandon
abandon
abandoned
abandoned
abandoning
abandoning
abandonment
abandonment
abandons
abandons
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
abbe
abbey
abbeys
abbot
abbots
Abbott
abbreviate
abbreviated
abbreviates
abbreviating
abbreviation
abbreviations
Abby
abdomen
abdomens
abdominal
abduct
abducted
abduction
abductions
abductor
abductors
abducts
Abe
abed
Abel
Abelian
Abelson
Aberdeen
Abernathy
aberrant
aberration
DROP TABLE t1;
...@@ -338,7 +338,7 @@ select * from t1 order by a; ...@@ -338,7 +338,7 @@ select * from t1 order by a;
drop table t1; drop table t1;
drop database test2; drop database test2;
# -- bug-5252 tinytext crashes plus no-commit result -- # -- bug-5252 tinytext crashes + no-commit result + replace --
set autocommit=0; set autocommit=0;
create table t1 ( create table t1 (
...@@ -352,6 +352,10 @@ select * from t1; ...@@ -352,6 +352,10 @@ select * from t1;
delete from t1; delete from t1;
select * from t1; select * from t1;
commit; commit;
replace t1 set a=2, b='y';
select * from t1;
delete from t1;
select * from t1;
drop table t1; drop table t1;
# -- bug-5013 insert empty string to text -- # -- bug-5013 insert empty string to text --
......
-- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# Basic test for different types of loading data
#
# should give duplicate key
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
--error 1022
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
DROP TABLE t1;
# now without a primary key we should be ok
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
DROP TABLE t1;
# End of 4.1 tests
...@@ -959,6 +959,8 @@ int ...@@ -959,6 +959,8 @@ int
NdbBlob::deletePartsUnknown(Uint32 part) NdbBlob::deletePartsUnknown(Uint32 part)
{ {
DBG("deletePartsUnknown [in] part=" << part << " count=all"); DBG("deletePartsUnknown [in] part=" << part << " count=all");
if (thePartSize == 0) // tinyblob
return 0;
static const unsigned maxbat = 256; static const unsigned maxbat = 256;
static const unsigned minbat = 1; static const unsigned minbat = 1;
unsigned bat = minbat; unsigned bat = minbat;
......
...@@ -841,9 +841,6 @@ insertPk(int style) ...@@ -841,9 +841,6 @@ insertPk(int style)
CHK(g_con->execute(NoCommit) == 0); CHK(g_con->execute(NoCommit) == 0);
CHK(writeBlobData(tup) == 0); CHK(writeBlobData(tup) == 0);
} }
// just another trap
if (urandom(10) == 0)
CHK(g_con->execute(NoCommit) == 0);
if (++n == g_opt.m_batch) { if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0); CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con); g_ndb->closeTransaction(g_con);
...@@ -965,21 +962,31 @@ static int ...@@ -965,21 +962,31 @@ static int
deletePk() deletePk()
{ {
DBG("--- deletePk ---"); DBG("--- deletePk ---");
unsigned n = 0;
CHK((g_con = g_ndb->startTransaction()) != 0);
for (unsigned k = 0; k < g_opt.m_rows; k++) { for (unsigned k = 0; k < g_opt.m_rows; k++) {
Tup& tup = g_tups[k]; Tup& tup = g_tups[k];
DBG("deletePk pk1=" << hex << tup.m_pk1); DBG("deletePk pk1=" << hex << tup.m_pk1);
CHK((g_con = g_ndb->startTransaction()) != 0);
CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0); CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0);
CHK(g_opr->deleteTuple() == 0); CHK(g_opr->deleteTuple() == 0);
CHK(g_opr->equal("PK1", tup.m_pk1) == 0); CHK(g_opr->equal("PK1", tup.m_pk1) == 0);
if (g_opt.m_pk2len != 0) if (g_opt.m_pk2len != 0)
CHK(g_opr->equal("PK2", tup.m_pk2) == 0); CHK(g_opr->equal("PK2", tup.m_pk2) == 0);
if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0); CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con); g_ndb->closeTransaction(g_con);
CHK((g_con = g_ndb->startTransaction()) != 0);
n = 0;
}
g_opr = 0; g_opr = 0;
g_con = 0;
tup.m_exists = false; tup.m_exists = false;
} }
if (n != 0) {
CHK(g_con->execute(Commit) == 0);
n = 0;
}
g_ndb->closeTransaction(g_con);
g_con = 0;
return 0; return 0;
} }
...@@ -1082,19 +1089,27 @@ static int ...@@ -1082,19 +1089,27 @@ static int
deleteIdx() deleteIdx()
{ {
DBG("--- deleteIdx ---"); DBG("--- deleteIdx ---");
unsigned n = 0;
CHK((g_con = g_ndb->startTransaction()) != 0);
for (unsigned k = 0; k < g_opt.m_rows; k++) { for (unsigned k = 0; k < g_opt.m_rows; k++) {
Tup& tup = g_tups[k]; Tup& tup = g_tups[k];
DBG("deleteIdx pk1=" << hex << tup.m_pk1); DBG("deleteIdx pk1=" << hex << tup.m_pk1);
CHK((g_con = g_ndb->startTransaction()) != 0);
CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0); CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0);
CHK(g_opx->deleteTuple() == 0); CHK(g_opx->deleteTuple() == 0);
CHK(g_opx->equal("PK2", tup.m_pk2) == 0); CHK(g_opx->equal("PK2", tup.m_pk2) == 0);
if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0); CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con); g_ndb->closeTransaction(g_con);
CHK((g_con = g_ndb->startTransaction()) != 0);
n = 0;
}
g_opx = 0; g_opx = 0;
g_con = 0;
tup.m_exists = false; tup.m_exists = false;
} }
if (n != 0) {
CHK(g_con->execute(Commit) == 0);
n = 0;
}
return 0; return 0;
} }
...@@ -1225,20 +1240,49 @@ deleteScan(bool idx) ...@@ -1225,20 +1240,49 @@ deleteScan(bool idx)
CHK(g_ops->getValue("PK2", tup.m_pk2) != 0); CHK(g_ops->getValue("PK2", tup.m_pk2) != 0);
CHK(g_con->execute(NoCommit) == 0); CHK(g_con->execute(NoCommit) == 0);
unsigned rows = 0; unsigned rows = 0;
unsigned n = 0;
while (1) { while (1) {
int ret; int ret;
tup.m_pk1 = (Uint32)-1; tup.m_pk1 = (Uint32)-1;
memset(tup.m_pk2, 'x', g_opt.m_pk2len); memset(tup.m_pk2, 'x', g_opt.m_pk2len);
CHK((ret = rs->nextResult()) == 0 || ret == 1); CHK((ret = rs->nextResult(true)) == 0 || ret == 1);
if (ret == 1) if (ret == 1)
break; break;
while (1) {
DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1); DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
CHK(rs->deleteTuple() == 0);
CHK(g_con->execute(NoCommit) == 0);
Uint32 k = tup.m_pk1 - g_opt.m_pk1off; Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
CHK(k < g_opt.m_rows && g_tups[k].m_exists); CHK(k < g_opt.m_rows && g_tups[k].m_exists);
g_tups[k].m_exists = false; g_tups[k].m_exists = false;
CHK(rs->deleteTuple() == 0);
rows++; rows++;
tup.m_pk1 = (Uint32)-1;
memset(tup.m_pk2, 'x', g_opt.m_pk2len);
CHK((ret = rs->nextResult(false)) == 0 || ret == 1 || ret == 2);
if (++n == g_opt.m_batch || ret == 2) {
DBG("execute batch: n=" << n << " ret=" << ret);
switch (0) {
case 0: // works normally
CHK(g_con->execute(NoCommit) == 0);
CHK(true || g_con->restart() == 0);
break;
case 1: // nonsense - g_con is invalid for 2nd batch
CHK(g_con->execute(Commit) == 0);
CHK(true || g_con->restart() == 0);
break;
case 2: // DBTC sendSignalErrorRefuseLab
CHK(g_con->execute(NoCommit) == 0);
CHK(g_con->restart() == 0);
break;
case 3: // 266 time-out
CHK(g_con->execute(Commit) == 0);
CHK(g_con->restart() == 0);
break;
}
n = 0;
}
if (ret == 2)
break;
}
} }
CHK(g_con->execute(Commit) == 0); CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con); g_ndb->closeTransaction(g_con);
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
#include <NdbSleep.h> #include <NdbSleep.h>
#include <NDBT.hpp> #include <NDBT.hpp>
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
bool commit_across_open_cursor, int parallelism=240);
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
...@@ -81,8 +82,18 @@ int main(int argc, char** argv){ ...@@ -81,8 +82,18 @@ int main(int argc, char** argv){
ndbout << " Table " << argv[i] << " does not exist!" << endl; ndbout << " Table " << argv[i] << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
// Check if we have any blobs
bool commit_across_open_cursor = true;
for (int j = 0; j < pTab->getNoOfColumns(); j++) {
NdbDictionary::Column::Type t = pTab->getColumn(j)->getType();
if (t == NdbDictionary::Column::Blob ||
t == NdbDictionary::Column::Text) {
commit_across_open_cursor = false;
break;
}
}
ndbout << "Deleting all from " << argv[i] << "..."; ndbout << "Deleting all from " << argv[i] << "...";
if(clear_table(&MyNdb, pTab) == NDBT_FAILED){ if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){
res = NDBT_FAILED; res = NDBT_FAILED;
ndbout << "FAILED" << endl; ndbout << "FAILED" << endl;
} }
...@@ -91,7 +102,8 @@ int main(int argc, char** argv){ ...@@ -91,7 +102,8 @@ int main(int argc, char** argv){
} }
int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism) int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
bool commit_across_open_cursor, int parallelism)
{ {
// Scan all records exclusive and delete // Scan all records exclusive and delete
// them one by one // them one by one
...@@ -153,8 +165,12 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism) ...@@ -153,8 +165,12 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
} while((check = rs->nextResult(false)) == 0); } while((check = rs->nextResult(false)) == 0);
if(check != -1){ if(check != -1){
if (commit_across_open_cursor) {
check = pTrans->execute(Commit); check = pTrans->execute(Commit);
pTrans->restart(); pTrans->restart(); // new tx id
} else {
check = pTrans->execute(NoCommit);
}
} }
err = pTrans->getNdbError(); err = pTrans->getNdbError();
...@@ -180,6 +196,10 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism) ...@@ -180,6 +196,10 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
} }
goto failed; goto failed;
} }
if (! commit_across_open_cursor && pTrans->execute(Commit) != 0) {
err = pTrans->getNdbError();
goto failed;
}
pNdb->closeTransaction(pTrans); pNdb->closeTransaction(pTrans);
return NDBT_OK; return NDBT_OK;
} }
......
...@@ -3046,11 +3046,25 @@ int ha_ndbcluster::end_bulk_insert() ...@@ -3046,11 +3046,25 @@ int ha_ndbcluster::end_bulk_insert()
"rows_inserted:%d, bulk_insert_rows: %d", "rows_inserted:%d, bulk_insert_rows: %d",
(int) m_rows_inserted, (int) m_bulk_insert_rows)); (int) m_rows_inserted, (int) m_bulk_insert_rows));
m_bulk_insert_not_flushed= FALSE; m_bulk_insert_not_flushed= FALSE;
if (execute_no_commit(this,trans) != 0) { if (m_transaction_on)
{
if (execute_no_commit(this, trans) != 0)
{
no_uncommitted_rows_execute_failure(); no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans); my_errno= error= ndb_err(trans);
} }
} }
else
{
if (execute_commit(this, trans) != 0)
{
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
}
int res= trans->restart();
DBUG_ASSERT(res == 0);
}
}
m_rows_inserted= (ha_rows) 0; m_rows_inserted= (ha_rows) 0;
m_rows_to_insert= (ha_rows) 1; m_rows_to_insert= (ha_rows) 1;
...@@ -4867,7 +4881,7 @@ bool ha_ndbcluster::low_byte_first() const ...@@ -4867,7 +4881,7 @@ bool ha_ndbcluster::low_byte_first() const
} }
bool ha_ndbcluster::has_transactions() bool ha_ndbcluster::has_transactions()
{ {
return m_transaction_on; return TRUE;
} }
const char* ha_ndbcluster::index_type(uint key_number) const char* ha_ndbcluster::index_type(uint key_number)
{ {
......
...@@ -285,8 +285,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -285,8 +285,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else else
error=read_sep_field(thd,info,table,fields,read_info,*enclosed, error=read_sep_field(thd,info,table,fields,read_info,*enclosed,
skip_lines); skip_lines);
if (table->file->end_bulk_insert()) if (table->file->end_bulk_insert() && !error)
error=1; /* purecov: inspected */ {
table->file->print_error(my_errno, MYF(0));
error= 1;
}
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->next_number_field=0; table->next_number_field=0;
} }
......
...@@ -11706,6 +11706,37 @@ static void test_bug12001() ...@@ -11706,6 +11706,37 @@ static void test_bug12001()
DIE_UNLESS(res==1); DIE_UNLESS(res==1);
} }
static void test_bug12744()
{
MYSQL_STMT *prep_stmt = NULL;
int rc;
myheader("test_bug12744");
prep_stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(prep_stmt, "SELECT 1", 8);
DIE_UNLESS(rc==0);
rc= mysql_kill(mysql, mysql_thread_id(mysql));
DIE_UNLESS(rc==0);
if (rc= mysql_stmt_execute(prep_stmt))
{
if (rc= mysql_stmt_reset(prep_stmt))
printf("OK!\n");
else
{
printf("Error!");
DIE_UNLESS(1==0);
}
}
else
{
fprintf(stderr, "expected error but no error occured\n");
DIE_UNLESS(1==0);
}
rc= mysql_stmt_close(prep_stmt);
}
/* /*
Bug#11718: query with function, join and order by returns wrong type Bug#11718: query with function, join and order by returns wrong type
*/ */
...@@ -12054,6 +12085,7 @@ static struct my_tests_st my_tests[]= { ...@@ -12054,6 +12085,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug8378", test_bug8378 }, { "test_bug8378", test_bug8378 },
{ "test_bug9735", test_bug9735 }, { "test_bug9735", test_bug9735 },
{ "test_bug11183", test_bug11183 }, { "test_bug11183", test_bug11183 },
{ "test_bug12744", test_bug12744 },
{ "test_bug12001", test_bug12001 }, { "test_bug12001", test_bug12001 },
{ "test_bug11718", test_bug11718 }, { "test_bug11718", test_bug11718 },
{ "test_bug12925", test_bug12925 }, { "test_bug12925", test_bug12925 },
......
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