Commit d467ad24 authored by unknown's avatar unknown

Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into kite-hub.kitebird.com:/src/extern/MySQL/bk/mysql-4.1

parents bb538317 6829605c
......@@ -68,3 +68,7 @@ Warnings:
Error 1259 ZLIB: Input data corrupted
Error 1256 Uncompressed data size too large; the maximum size is 1048576 (probably, length of uncompressed data was corrupted)
drop table t1;
set @@max_allowed_packet=1048576*100;
select length(compress(repeat('aaaaaaaaaa', 10000000)));
length(compress(repeat('aaaaaaaaaa', 10000000)))
97214
......@@ -18,12 +18,12 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int) ENGINE=ndbcluster;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ndbcluster 9 Dynamic 100 0 0 NULL 0 0 1 NULL NULL NULL latin1_swedish_ci NULL
t1 ndbcluster 9 Dynamic 0 0 0 NULL 0 0 1 NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values
(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ndbcluster 9 Dynamic 100 0 0 NULL 0 0 102 NULL NULL NULL latin1_swedish_ci NULL
t1 ndbcluster 9 Dynamic 9 0 0 NULL 0 0 102 NULL NULL NULL latin1_swedish_ci NULL
select * from t1 order by col1;
col1 col2 col3 col4 col5 col6 to_be_deleted
0 4 3 5 PENDING 1 7
......@@ -43,7 +43,7 @@ change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ndbcluster 9 Dynamic 100 0 0 NULL 0 0 102 NULL NULL NULL latin1_swedish_ci NULL
t1 ndbcluster 9 Dynamic 9 0 0 NULL 0 0 102 NULL NULL NULL latin1_swedish_ci NULL
select * from t1 order by col1;
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
1 0 3 4 5 PENDING 0000-00-00 00:00:00
......@@ -58,7 +58,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ndbcluster 9 Dynamic 100 0 0 NULL 0 0 103 NULL NULL NULL latin1_swedish_ci NULL
t1 ndbcluster 9 Dynamic 10 0 0 NULL 0 0 103 NULL NULL NULL latin1_swedish_ci NULL
select * from t1 order by col1;
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
1 0 3 4 5 PENDING 0000-00-00 00:00:00
......
......@@ -150,7 +150,7 @@ insert into t1 values(9,'b9',999,'dd9');
commit;
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100
1 SIMPLE t1 ALL NULL NULL NULL NULL 9
select * from t1 order by a;
a b c d
1 b1 111 dd1
......@@ -185,7 +185,7 @@ insert into t1 values(2,@b2,222,@d2);
commit;
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3)
from t1 order by a;
a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3)
......
......@@ -421,11 +421,25 @@ INSERT INTO t1 VALUES
(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10);
ERROR 23000: Duplicate entry '10' for key 1
begin;
SELECT COUNT(*) FROM t1;
COUNT(*)
2000
INSERT INTO t1 VALUES
(2001,2001,2001),(2002,2002,2002),(2003,2003,2003),(2004,2004,2004),(2005,2005,2005);
SELECT COUNT(*) FROM t1;
COUNT(*)
2005
INSERT INTO t1 VALUES
(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10);
ERROR 23000: Duplicate entry '10' for key 1
SELECT COUNT(*) FROM t1;
COUNT(*)
2000
commit;
SELECT COUNT(*) FROM t1;
COUNT(*)
2000
insert into t1 select * from t1 where b < 10 order by pk1;
ERROR 23000: Duplicate entry '9' for key 1
DROP TABLE t1;
......@@ -35,3 +35,10 @@ select length(a) from t1;
select length(uncompress(a)) from t1;
drop table t1;
#
# Bug #5497: a problem with large strings
#
set @@max_allowed_packet=1048576*100;
select length(compress(repeat('aaaaaaaaaa', 10000000)));
......@@ -443,13 +443,20 @@ begin;
#
# Insert duplicate rows, inside transaction
#
# since failing inserts rollbacks whole transaction
# all select count (except second) return same value
#
SELECT COUNT(*) FROM t1;
INSERT INTO t1 VALUES
(2001,2001,2001),(2002,2002,2002),(2003,2003,2003),(2004,2004,2004),(2005,2005,2005);
SELECT COUNT(*) FROM t1;
--error 1062
INSERT INTO t1 VALUES
(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10);
SELECT COUNT(*) FROM t1;
commit;
SELECT COUNT(*) FROM t1;
#
# Insert duplicate rows using "insert .. select"
......
......@@ -42,7 +42,7 @@ my_string fn_format(my_string to, const char *name, const char *dir,
/* Use given directory */
convert_dirname(dev,dir,NullS); /* Fix to this OS */
}
else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(name))
else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(dev))
{
/* Put 'dir' before the given path */
strmake(buff,dev,sizeof(buff)-1);
......
......@@ -1066,6 +1066,9 @@ public:
Dictionary(NdbDictionaryImpl&);
const Table * getIndexTable(const char * indexName,
const char * tableName);
public:
const Table * getTable(const char * name, void **data);
void set_local_table_data_size(unsigned sz);
};
};
......
This diff is collapsed.
......@@ -21,6 +21,31 @@
#include <NdbCondition.h>
#include <NdbSleep.h>
Ndb_local_table_info *
Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz)
{
void *data= malloc(sizeof(NdbTableImpl)+sz-1);
if (data == 0)
return 0;
memset(data,0,sizeof(NdbTableImpl)+sz-1);
new (data) Ndb_local_table_info(table_impl);
return (Ndb_local_table_info *) data;
}
void Ndb_local_table_info::destroy(Ndb_local_table_info *info)
{
free((void *)info);
}
Ndb_local_table_info::Ndb_local_table_info(NdbTableImpl *table_impl)
{
m_table_impl= table_impl;
}
Ndb_local_table_info::~Ndb_local_table_info()
{
}
LocalDictCache::LocalDictCache(){
m_tableHash.createHashTable();
}
......@@ -29,22 +54,24 @@ LocalDictCache::~LocalDictCache(){
m_tableHash.releaseHashTable();
}
NdbTableImpl *
Ndb_local_table_info *
LocalDictCache::get(const char * name){
const Uint32 len = strlen(name);
return m_tableHash.getData(name, len);
}
void
LocalDictCache::put(const char * name, NdbTableImpl * tab){
const Uint32 id = tab->m_tableId;
LocalDictCache::put(const char * name, Ndb_local_table_info * tab_info){
const Uint32 id = tab_info->m_table_impl->m_tableId;
m_tableHash.insertKey(name, strlen(name), id, tab);
m_tableHash.insertKey(name, strlen(name), id, tab_info);
}
void
LocalDictCache::drop(const char * name){
m_tableHash.deleteKey(name, strlen(name));
Ndb_local_table_info *info= m_tableHash.deleteKey(name, strlen(name));
DBUG_ASSERT(info != 0);
Ndb_local_table_info::destroy(info);
}
/*****************************************************************
......
......@@ -27,6 +27,17 @@
#include <Ndb.hpp>
#include "NdbLinHash.hpp"
class Ndb_local_table_info {
public:
static Ndb_local_table_info *create(NdbTableImpl *table_impl, Uint32 sz=0);
static void destroy(Ndb_local_table_info *);
NdbTableImpl *m_table_impl;
char m_local_data[1];
private:
Ndb_local_table_info(NdbTableImpl *table_impl);
~Ndb_local_table_info();
};
/**
* A non thread safe dict cache
*/
......@@ -35,12 +46,12 @@ public:
LocalDictCache();
~LocalDictCache();
NdbTableImpl * get(const char * name);
Ndb_local_table_info * get(const char * name);
void put(const char * name, NdbTableImpl *);
void put(const char * name, Ndb_local_table_info *);
void drop(const char * name);
NdbLinHash<NdbTableImpl> m_tableHash; // On name
NdbLinHash<Ndb_local_table_info> m_tableHash; // On name
};
/**
......
......@@ -753,9 +753,11 @@ Uint64
Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize)
{
DEBUG_TRACE("getAutoIncrementValue");
const NdbTableImpl* table = theDictionary->getTable(aTableName);
if (table == 0)
const char * internalTableName = internalizeTableName(aTableName);
Ndb_local_table_info *info= theDictionary->get_local_table_info(internalTableName);
if (info == 0)
return ~0;
const NdbTableImpl *table= info->m_table_impl;
Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize);
return tupleId;
}
......@@ -832,11 +834,13 @@ bool
Ndb::setAutoIncrementValue(const char* aTableName, Uint64 val, bool increase)
{
DEBUG_TRACE("setAutoIncrementValue " << val);
const NdbTableImpl* table = theDictionary->getTable(aTableName);
if (table == 0) {
const char * internalTableName= internalizeTableName(aTableName);
Ndb_local_table_info *info= theDictionary->get_local_table_info(internalTableName);
if (info == 0) {
theError= theDictionary->getNdbError();
return false;
}
const NdbTableImpl* table= info->m_table_impl;
return setTupleIdInNdb(table->m_tableId, val, increase);
}
......
......@@ -681,13 +681,23 @@ NdbDictionary::Dictionary::alterTable(const Table & t){
}
const NdbDictionary::Table *
NdbDictionary::Dictionary::getTable(const char * name){
NdbTableImpl * t = m_impl.getTable(name);
NdbDictionary::Dictionary::getTable(const char * name, void **data){
NdbTableImpl * t = m_impl.getTable(name, data);
if(t)
return t->m_facade;
return 0;
}
void NdbDictionary::Dictionary::set_local_table_data_size(unsigned sz)
{
m_impl.m_local_table_data_size= sz;
}
const NdbDictionary::Table *
NdbDictionary::Dictionary::getTable(const char * name){
return getTable(name, 0);
}
void
NdbDictionary::Dictionary::invalidateTable(const char * name){
NdbTableImpl * t = m_impl.getTable(name);
......
......@@ -589,17 +589,19 @@ NdbDictionaryImpl::NdbDictionaryImpl(Ndb &ndb,
m_ndb(ndb)
{
m_globalHash = 0;
m_local_table_data_size= 0;
}
static int f_dictionary_count = 0;
NdbDictionaryImpl::~NdbDictionaryImpl()
{
NdbElement_t<NdbTableImpl> * curr = m_localHash.m_tableHash.getNext(0);
NdbElement_t<Ndb_local_table_info> * curr = m_localHash.m_tableHash.getNext(0);
if(m_globalHash){
while(curr != 0){
m_globalHash->lock();
m_globalHash->release(curr->theData);
m_globalHash->release(curr->theData->m_table_impl);
Ndb_local_table_info::destroy(curr->theData);
m_globalHash->unlock();
curr = m_localHash.m_tableHash.getNext(curr);
......@@ -620,7 +622,37 @@ NdbDictionaryImpl::~NdbDictionaryImpl()
}
}
Ndb_local_table_info *
NdbDictionaryImpl::fetchGlobalTableImpl(const char * internalTableName)
{
NdbTableImpl *impl;
m_globalHash->lock();
impl = m_globalHash->get(internalTableName);
m_globalHash->unlock();
if (impl == 0){
impl = m_receiver.getTable(internalTableName, m_ndb.usingFullyQualifiedNames());
m_globalHash->lock();
m_globalHash->put(internalTableName, impl);
m_globalHash->unlock();
if(impl == 0){
return 0;
}
}
Ndb_local_table_info *info= Ndb_local_table_info::create(impl, m_local_table_data_size);
m_localHash.put(internalTableName, info);
m_ndb.theFirstTupleId[impl->getTableId()] = ~0;
m_ndb.theLastTupleId[impl->getTableId()] = ~0;
addBlobTables(*impl);
return info;
}
#if 0
bool
......@@ -1504,7 +1536,6 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
: createTable(&tSignal, ptr);
if (!alter && haveAutoIncrement) {
// if (!ndb.setAutoIncrementValue(impl.m_internalName.c_str(), autoIncrementValue)) {
if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(), autoIncrementValue)) {
if (ndb.theError.code == 0) {
m_error.code = 4336;
......@@ -1775,11 +1806,12 @@ NdbIndexImpl*
NdbDictionaryImpl::getIndexImpl(const char * externalName,
const char * internalName)
{
NdbTableImpl* tab = getTableImpl(internalName);
if(tab == 0){
Ndb_local_table_info * info = get_local_table_info(internalName);
if(info == 0){
m_error.code = 4243;
return 0;
}
NdbTableImpl * tab = info->m_table_impl;
if(tab->m_indexType == NdbDictionary::Index::Undefined){
// Not an index
......
......@@ -390,8 +390,8 @@ public:
int listObjects(List& list, NdbDictionary::Object::Type type);
int listIndexes(List& list, const char * tableName);
NdbTableImpl * getTable(const char * tableName);
NdbTableImpl * getTableImpl(const char * internalName);
NdbTableImpl * getTable(const char * tableName, void **data= 0);
Ndb_local_table_info * get_local_table_info(const char * internalName);
NdbIndexImpl * getIndex(const char * indexName,
const char * tableName);
NdbIndexImpl * getIndexImpl(const char * name, const char * internalName);
......@@ -400,6 +400,7 @@ public:
const NdbError & getNdbError() const;
NdbError m_error;
Uint32 m_local_table_data_size;
LocalDictCache m_localHash;
GlobalDictCache * m_globalHash;
......@@ -410,6 +411,8 @@ public:
NdbDictInterface m_receiver;
Ndb & m_ndb;
private:
Ndb_local_table_info * fetchGlobalTableImpl(const char * internalName);
};
inline
......@@ -598,45 +601,28 @@ NdbDictionaryImpl::getImpl(const NdbDictionary::Dictionary & t){
inline
NdbTableImpl *
NdbDictionaryImpl::getTable(const char * tableName)
NdbDictionaryImpl::getTable(const char * tableName, void **data)
{
const char * internalTableName = m_ndb.internalizeTableName(tableName);
return getTableImpl(internalTableName);
Ndb_local_table_info *info= get_local_table_info(internalTableName);
if (info == 0) {
return 0;
}
if (data) {
*data= info->m_local_data;
}
return info->m_table_impl;
}
inline
NdbTableImpl *
NdbDictionaryImpl::getTableImpl(const char * internalTableName)
Ndb_local_table_info *
NdbDictionaryImpl::get_local_table_info(const char * internalTableName)
{
NdbTableImpl *ret = m_localHash.get(internalTableName);
if (ret != 0) {
return ret; // autoincrement already initialized
Ndb_local_table_info *info= m_localHash.get(internalTableName);
if (info != 0) {
return info; // autoincrement already initialized
}
m_globalHash->lock();
ret = m_globalHash->get(internalTableName);
m_globalHash->unlock();
if (ret == 0){
ret = m_receiver.getTable(internalTableName, m_ndb.usingFullyQualifiedNames());
m_globalHash->lock();
m_globalHash->put(internalTableName, ret);
m_globalHash->unlock();
if(ret == 0){
return 0;
}
}
m_localHash.put(internalTableName, ret);
m_ndb.theFirstTupleId[ret->getTableId()] = ~0;
m_ndb.theLastTupleId[ret->getTableId()] = ~0;
addBlobTables(*ret);
return ret;
return fetchGlobalTableImpl(internalTableName);
}
inline
......@@ -654,9 +640,9 @@ NdbDictionaryImpl::getIndex(const char * indexName,
internalIndexName = m_ndb.internalizeTableName(indexName); // Index is also a table
}
if (internalIndexName) {
NdbTableImpl * tab = getTableImpl(internalIndexName);
if (tab) {
Ndb_local_table_info * info = get_local_table_info(internalIndexName);
if (info) {
NdbTableImpl * tab = info->m_table_impl;
if (tab->m_index == 0)
tab->m_index = getIndexImpl(indexName, internalIndexName);
if (tab->m_index != 0)
......
......@@ -59,7 +59,7 @@ public:
void releaseHashTable(void);
int insertKey(const char * str, Uint32 len, Uint32 lkey1, C* data);
int deleteKey(const char * str, Uint32 len);
C *deleteKey(const char * str, Uint32 len);
C* getData(const char *, Uint32);
Uint32* getKey(const char *, Uint32);
......@@ -277,7 +277,7 @@ NdbLinHash<C>::getData( const char* str, Uint32 len ){
template <class C>
inline
int
C *
NdbLinHash<C>::deleteKey ( const char* str, Uint32 len){
const Uint32 hash = Hash(str, len);
int dir, seg;
......@@ -288,19 +288,21 @@ NdbLinHash<C>::deleteKey ( const char* str, Uint32 len){
for(NdbElement_t<C> * chain = *chainp; chain != 0; chain = chain->next){
if(chain->len == len && !memcmp(chain->str, str, len)){
if (oldChain == 0) {
C *data= chain->theData;
delete chain;
* chainp = 0;
return 1;
return data;
} else {
C *data= chain->theData;
oldChain->next = chain->next;
delete chain;
return 1;
return data;
}
} else {
oldChain = chain;
}
}
return -1; /* Element doesn't exist */
return 0; /* Element doesn't exist */
}
template <class C>
......
......@@ -674,7 +674,6 @@ void NdbScanOperation::closeScan()
if(m_api_receivers_count+m_conf_receivers_count){
// Send close scan
ndbout_c("sending close %d %d", m_api_receivers_count, m_conf_receivers_count);
send_next_scan(0, true); // Close scan
}
......
......@@ -1138,90 +1138,93 @@ UtilTransactions::readRowFromTableAndIndex(Ndb* pNdb,
*/
NdbIndexOperation* pIndexOp= NULL;
NdbIndexScanOperation *pScanOp= NULL;
{
void* pOpCheck= NULL;
if (indexType == NdbDictionary::Index::UniqueHashIndex) {
pOpCheck= pIndexOp= pTrans1->getNdbIndexOperation(indexName, tab.getName());
} else {
pOpCheck= pScanOp= pTrans1->getNdbIndexScanOperation(indexName, tab.getName());
}
NdbOperation *pIOp= 0;
if (pOpCheck == NULL) {
ERR(pTrans1->getNdbError());
goto close_all;
bool null_found= false;
for(a = 0; a<(int)pIndex->getNoOfColumns(); a++){
const NdbDictionary::Column * col = pIndex->getColumn(a);
if (row.attributeStore(col->getName())->isNULL())
{
null_found= true;
break;
}
}
const char * tabName= tab.getName();
if(!null_found)
{
bool not_ok;
if (pIndexOp) {
not_ok = pIndexOp->readTuple() == -1;
if (indexType == NdbDictionary::Index::UniqueHashIndex) {
pIOp= pIndexOp= pTrans1->getNdbIndexOperation(indexName, tabName);
} else {
not_ok = (cursor= pScanOp->readTuples()) == 0;
pIOp= pScanOp= pTrans1->getNdbIndexScanOperation(indexName, tabName);
}
if( not_ok ) {
if (pIOp == NULL) {
ERR(pTrans1->getNdbError());
goto close_all;
}
}
{
bool not_ok;
if (pIndexOp) {
not_ok = pIndexOp->readTuple() == -1;
} else {
not_ok = (cursor= pScanOp->readTuples()) == 0;
}
if( not_ok ) {
ERR(pTrans1->getNdbError());
goto close_all;
}
}
// Define primary keys for index
#if VERBOSE
printf("SI: ");
printf("SI: ");
#endif
for(a = 0; a<(int)pIndex->getNoOfColumns(); a++){
const NdbDictionary::Column * col = pIndex->getColumn(a);
int r;
if (pIndexOp)
r = pIndexOp->equal(col->getName(), row.attributeStore(col->getName())->aRef());
else {
// setBound not possible for null attributes
for(a = 0; a<(int)pIndex->getNoOfColumns(); a++){
const NdbDictionary::Column * col = pIndex->getColumn(a);
int r;
if ( !row.attributeStore(col->getName())->isNULL() ) {
r = pScanOp->setBound(col->getName(),
NdbIndexScanOperation::BoundEQ,
row.attributeStore(col->getName())->aRef());
if(pIOp->equal(col->getName(),
row.attributeStore(col->getName())->aRef()) != 0){
ERR(pTrans1->getNdbError());
goto close_all;
}
}
}
if (r != 0){
ERR(pTrans1->getNdbError());
goto close_all;
}
#if VERBOSE
printf("%s = %d: ", col->getName(), row.attributeStore(a)->aRef());
printf("%s = %d: ", col->getName(), row.attributeStore(a)->aRef());
#endif
}
}
#if VERBOSE
printf("\n");
printf("\n");
#endif
// Read all attributes
// Read all attributes
#if VERBOSE
printf("Reading %u attributes: ", tab.getNoOfColumns());
printf("Reading %u attributes: ", tab.getNoOfColumns());
#endif
for(a = 0; a<tab.getNoOfColumns(); a++){
void* pCheck;
if (pIndexOp)
pCheck= indexRow.attributeStore(a)=
pIndexOp->getValue(tab.getColumn(a)->getName());
else
pCheck= indexRow.attributeStore(a)=
pScanOp->getValue(tab.getColumn(a)->getName());
if(pCheck == NULL) {
ERR(pTrans1->getNdbError());
goto close_all;
}
for(a = 0; a<tab.getNoOfColumns(); a++){
void* pCheck;
pCheck= indexRow.attributeStore(a)=
pIOp->getValue(tab.getColumn(a)->getName());
if(pCheck == NULL) {
ERR(pTrans1->getNdbError());
goto close_all;
}
#if VERBOSE
printf("%s ", tab.getColumn(a)->getName());
printf("%s ", tab.getColumn(a)->getName());
#endif
}
}
#if VERBOSE
printf("\n");
#endif
check = pTrans1->execute(Commit);
if( check == -1 ) {
const NdbError err = pTrans1->getNdbError();
......@@ -1238,41 +1241,43 @@ UtilTransactions::readRowFromTableAndIndex(Ndb* pNdb,
ndbout << "row: " << row.c_str().c_str() << endl;
goto close_all;
}
/**
* Compare the two rows
*/
if (pScanOp) {
if (cursor->nextResult() != 0){
const NdbError err = pTrans1->getNdbError();
ERR(err);
ndbout << "Error when comparing records - index op next_result missing" << endl;
ndbout << "row: " << row.c_str().c_str() << endl;
goto close_all;
if(!null_found){
if (pScanOp) {
if (cursor->nextResult() != 0){
const NdbError err = pTrans1->getNdbError();
ERR(err);
ndbout << "Error when comparing records - index op next_result missing" << endl;
ndbout << "row: " << row.c_str().c_str() << endl;
goto close_all;
}
}
}
if (!(tabRow.c_str() == indexRow.c_str())){
ndbout << "Error when comapring records" << endl;
ndbout << " tabRow: \n" << tabRow.c_str().c_str() << endl;
ndbout << " indexRow: \n" << indexRow.c_str().c_str() << endl;
goto close_all;
}
if (pScanOp) {
if (cursor->nextResult() == 0){
ndbout << "Error when comparing records - index op next_result to many" << endl;
ndbout << "row: " << row.c_str().c_str() << endl;
if (!(tabRow.c_str() == indexRow.c_str())){
ndbout << "Error when comapring records" << endl;
ndbout << " tabRow: \n" << tabRow.c_str().c_str() << endl;
ndbout << " indexRow: \n" << indexRow.c_str().c_str() << endl;
goto close_all;
}
if (pScanOp) {
if (cursor->nextResult() == 0){
ndbout << "Error when comparing records - index op next_result to many" << endl;
ndbout << "row: " << row.c_str().c_str() << endl;
goto close_all;
}
}
}
return_code= NDBT_OK;
goto close_all;
}
close_all:
close_all:
if (cursor)
cursor->close();
if (pTrans1)
pNdb->closeTransaction(pTrans1);
return return_code;
}
......@@ -92,7 +92,7 @@ libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@"
libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
include="-I$pkgincludedir"
embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@"
embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@ $client_libs"
embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
# Remove some options that a client doesn't have to care about
......
This diff is collapsed.
......@@ -63,6 +63,20 @@ typedef struct st_ndbcluster_share {
uint table_name_length,use_count;
} NDB_SHARE;
/*
Place holder for ha_ndbcluster thread specific data
*/
class Thd_ndb {
public:
Thd_ndb();
~Thd_ndb();
Ndb *ndb;
ulong count;
uint lock_count;
int error;
};
class ha_ndbcluster: public handler
{
public:
......@@ -147,8 +161,8 @@ class ha_ndbcluster: public handler
void start_bulk_insert(ha_rows rows);
int end_bulk_insert();
static Ndb* seize_ndb();
static void release_ndb(Ndb* ndb);
static Thd_ndb* seize_thd_ndb();
static void release_thd_ndb(Thd_ndb* thd_ndb);
uint8 table_cache_type() { return HA_CACHE_TBL_NOCACHE; }
private:
......@@ -214,7 +228,8 @@ class ha_ndbcluster: public handler
NdbConnection *m_active_trans;
NdbResultSet *m_active_cursor;
Ndb *m_ndb;
void *m_table;
void *m_table;
void *m_table_info;
char m_dbname[FN_HEADLEN];
//char m_schemaname[FN_HEADLEN];
char m_tabname[FN_HEADLEN];
......@@ -238,6 +253,12 @@ class ha_ndbcluster: public handler
char *blobs_buffer;
uint32 blobs_buffer_size;
uint dupkey;
void records_update();
void no_uncommitted_rows_execute_failure();
void no_uncommitted_rows_update(int);
void no_uncommitted_rows_init(THD *);
void no_uncommitted_rows_reset(THD *);
};
bool ndbcluster_init(void);
......
......@@ -2412,14 +2412,22 @@ String *Item_load_file::val_str(String *str)
String *file_name;
File file;
MY_STAT stat_info;
char path[FN_REFLEN];
DBUG_ENTER("load_file");
if (!(file_name= args[0]->val_str(str)) ||
if (!(file_name= args[0]->val_str(str))
#ifndef NO_EMBEDDED_ACCESS_CHECKS
!(current_thd->master_access & FILE_ACL) ||
|| !(current_thd->master_access & FILE_ACL)
#endif
!my_stat(file_name->c_ptr(), &stat_info, MYF(MY_WME)))
)
goto err;
(void) fn_format(path, file_name->c_ptr(), mysql_real_data_home, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
if (!my_stat(path, &stat_info, MYF(MY_WME)))
goto err;
if (!(stat_info.st_mode & S_IROTH))
{
/* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */
......@@ -2723,11 +2731,17 @@ String *Item_func_compress::val_str(String *str)
compress(compress(compress(...)))
I.e. zlib give number 'at least'..
*/
ulong new_size= (ulong)((res->length()*120)/100)+12;
ulong new_size= res->length() + res->length() / 5 + 12;
buffer.realloc((uint32)new_size + 4 + 1);
Byte *body= ((Byte*)buffer.ptr()) + 4;
// Will check new_size overflow: new_size <= res->length()
if (((uint32) new_size <= res->length()) ||
buffer.realloc((uint32) new_size + 4 + 1))
{
null_value= 1;
return 0;
}
Byte *body= ((Byte*)buffer.ptr()) + 4;
// As far as we have checked res->is_empty() we can use ptr()
if ((err= compress(body, &new_size,
......
......@@ -1126,14 +1126,14 @@ static void set_effective_user(struct passwd *user_info)
{
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
DBUG_ASSERT(user_info);
if (setegid(user_info->pw_gid) == -1)
if (setregid((gid_t)-1, user_info->pw_gid) == -1)
{
sql_perror("setegid");
sql_perror("setregid");
unireg_abort(1);
}
if (seteuid(user_info->pw_uid) == -1)
if (setreuid((uid_t)-1, user_info->pw_uid) == -1)
{
sql_perror("seteuid");
sql_perror("setreuid");
unireg_abort(1);
}
#endif
......@@ -2657,9 +2657,9 @@ server.");
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY)
if (locked_in_memory && !getuid())
{
if (seteuid(0) == -1)
if (setreuid((uid_t)-1, 0) == -1)
{ // this should never happen
sql_perror("seteuid");
sql_perror("setreuid");
unireg_abort(1);
}
if (mlockall(MCL_CURRENT))
......
......@@ -892,9 +892,14 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
option|= MY_REPLACE_DIR; // Force use of db directory
#endif
strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "",
NullS);
(void) fn_format(path, exchange->file_name, path, "", option);
if (!dirname_length(exchange->file_name))
{
strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "", NullS);
(void) fn_format(path, exchange->file_name, path, "", option);
}
else
(void) fn_format(path, exchange->file_name, mysql_real_data_home, "", option);
if (!access(path, F_OK))
{
my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);
......
......@@ -764,9 +764,8 @@ class THD :public ilink,
THD_TRANS all; // Trans since BEGIN WORK
THD_TRANS stmt; // Trans for current statement
uint bdb_lock_count;
uint ndb_lock_count;
#ifdef HAVE_NDBCLUSTER_DB
void* ndb;
void* thd_ndb;
#endif
bool on;
/*
......
......@@ -179,17 +179,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
ex->file_name+=dirname_length(ex->file_name);
#endif
if (!dirname_length(ex->file_name) &&
strlen(ex->file_name)+strlen(mysql_real_data_home)+strlen(tdb)+3 <
FN_REFLEN)
if (!dirname_length(ex->file_name))
{
(void) sprintf(name,"%s%s/%s",mysql_real_data_home,tdb,ex->file_name);
unpack_filename(name,name); /* Convert to system format */
strxnmov(name, FN_REFLEN, mysql_real_data_home, tdb, NullS);
(void) fn_format(name, ex->file_name, name, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
}
else
{
my_load_path(name, ex->file_name, mysql_real_data_home);
unpack_filename(name, name);
(void) fn_format(name, ex->file_name, mysql_real_data_home, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
#if !defined(__WIN__) && !defined(OS2) && ! defined(__NETWARE__)
MY_STAT stat_info;
if (!my_stat(name,&stat_info,MYF(MY_WME)))
......
......@@ -2610,7 +2610,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
else
{
if (!access(fn_format(new_name_buff,new_name_buff,new_db,reg_ext,0),
char dir_buff[FN_REFLEN];
strxnmov(dir_buff, FN_REFLEN, mysql_real_data_home, new_db, NullS);
if (!access(fn_format(new_name_buff,new_name_buff,dir_buff,reg_ext,0),
F_OK))
{
/* Table will be closed in do_command() */
......
......@@ -1345,10 +1345,10 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs,
}
if (ptr[0] == '\0' && ptr[1] == w_one) /* '_' in SQL */
{
*min_str++= (char) cs->min_sort_char >> 8;
*min_str++= (char) cs->min_sort_char & 255;
*max_str++= (char) cs->max_sort_char >> 8;
*max_str++= (char) cs->max_sort_char & 255;
*min_str++= (char) (cs->min_sort_char >> 8);
*min_str++= (char) (cs->min_sort_char & 255);
*max_str++= (char) (cs->max_sort_char >> 8);
*max_str++= (char) (cs->max_sort_char & 255);
continue;
}
if (ptr[0] == '\0' && ptr[1] == w_many) /* '%' in SQL */
......@@ -1358,8 +1358,8 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs,
do {
*min_str++ = 0;
*min_str++ = 0;
*max_str++ = (char) cs->max_sort_char >>8;
*max_str++ = (char) cs->max_sort_char & 255;
*max_str++ = (char) (cs->max_sort_char >> 8);
*max_str++ = (char) (cs->max_sort_char & 255);
} while (min_str + 1 < min_end);
return 0;
}
......
......@@ -10123,9 +10123,9 @@ static void test_bug4231()
bzero(tm, sizeof(tm));
bind[0].buffer_type= MYSQL_TYPE_TIME;
bind[0].buffer= (void*) tm;
bind[0].buffer= &tm[0];
bind[1].buffer_type= MYSQL_TYPE_TIME;
bind[1].buffer= (void*) tm+1;
bind[1].buffer= &tm[1];
mysql_stmt_bind_param(stmt, bind);
check_execute(stmt, rc);
......
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