Commit 96188c81 authored by mskold@mysql.com's avatar mskold@mysql.com

Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb

into mysql.com:/usr/local/home/marty/MySQL/test/mysql-5.0-ndb
parents 59a986d9 63a19c47
......@@ -31,18 +31,25 @@ functions */
#define HAVE_SMEM 1
#if defined(__NT__)
#define SYSTEM_TYPE "NT"
#elif defined(__WIN2000__)
#define SYSTEM_TYPE "WIN2000"
#if defined(_WIN64) || defined(WIN64)
#define SYSTEM_TYPE "Win64"
#elif defined(_WIN32) || defined(WIN32)
#define SYSTEM_TYPE "Win32"
#else
#define SYSTEM_TYPE "Win95/Win98"
#define SYSTEM_TYPE "Windows"
#endif
#if defined(_WIN64) || defined(WIN64)
#define MACHINE_TYPE "ia64" /* Define to machine type name */
#if defined(_M_IA64)
#define MACHINE_TYPE "ia64"
#elif defined(_M_IX86)
#define MACHINE_TYPE "ia32"
#elif defined(_M_ALPHA)
#define MACHINE_TYPE "axp"
#else
#define MACHINE_TYPE "i32" /* Define to machine type name */
#define MACHINE_TYPE "unknown" /* Define to machine type name */
#endif
#if !(defined(_WIN64) || defined(WIN64))
#ifndef _WIN32
#define _WIN32 /* Compatible with old source */
#endif
......
......@@ -554,6 +554,89 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59';
count(*)-9
0
drop table t1;
create table t1 (
a int primary key,
s decimal(12),
t decimal(12, 5),
u decimal(12) unsigned,
v decimal(12, 5) unsigned,
key (s),
key (t),
key (u),
key (v)
) engine=ndb;
insert into t1 values
( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042),
( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003),
( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488),
( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013),
( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002),
( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018),
( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001),
( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374),
( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000),
( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008);
select count(*)- 5 from t1 use index (s) where s < -000000000007;
count(*)- 5
0
select count(*)- 7 from t1 use index (s) where s <= -000000000007;
count(*)- 7
0
select count(*)- 2 from t1 use index (s) where s = -000000000007;
count(*)- 2
0
select count(*)- 5 from t1 use index (s) where s >= -000000000007;
count(*)- 5
0
select count(*)- 3 from t1 use index (s) where s > -000000000007;
count(*)- 3
0
select count(*)- 4 from t1 use index (t) where t < -0000061.00003;
count(*)- 4
0
select count(*)- 5 from t1 use index (t) where t <= -0000061.00003;
count(*)- 5
0
select count(*)- 1 from t1 use index (t) where t = -0000061.00003;
count(*)- 1
0
select count(*)- 6 from t1 use index (t) where t >= -0000061.00003;
count(*)- 6
0
select count(*)- 5 from t1 use index (t) where t > -0000061.00003;
count(*)- 5
0
select count(*)- 2 from t1 use index (u) where u < 000000000061;
count(*)- 2
0
select count(*)- 4 from t1 use index (u) where u <= 000000000061;
count(*)- 4
0
select count(*)- 2 from t1 use index (u) where u = 000000000061;
count(*)- 2
0
select count(*)- 8 from t1 use index (u) where u >= 000000000061;
count(*)- 8
0
select count(*)- 6 from t1 use index (u) where u > 000000000061;
count(*)- 6
0
select count(*)- 5 from t1 use index (v) where v < 0000965.00042;
count(*)- 5
0
select count(*)- 6 from t1 use index (v) where v <= 0000965.00042;
count(*)- 6
0
select count(*)- 1 from t1 use index (v) where v = 0000965.00042;
count(*)- 1
0
select count(*)- 5 from t1 use index (v) where v >= 0000965.00042;
count(*)- 5
0
select count(*)- 4 from t1 use index (v) where v > 0000965.00042;
count(*)- 4
0
drop table t1;
create table t1(a int primary key, b int not null, index(b));
insert into t1 values (1,1), (2,2);
set autocommit=0;
......
......@@ -2059,6 +2059,16 @@ call bug6029()|
1136
drop procedure bug6029|
drop table t3|
drop procedure if exists bug8540|
create procedure bug8540()
begin
declare x int default 1;
select x as y, x+0 as z;
end|
call bug8540()|
y z
1 1
drop procedure bug8540|
drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
drop procedure if exists ifac|
......
......@@ -280,6 +280,58 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59';
drop table t1;
# decimal (not the new 5.0 thing)
create table t1 (
a int primary key,
s decimal(12),
t decimal(12, 5),
u decimal(12) unsigned,
v decimal(12, 5) unsigned,
key (s),
key (t),
key (u),
key (v)
) engine=ndb;
#
insert into t1 values
( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042),
( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003),
( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488),
( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013),
( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002),
( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018),
( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001),
( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374),
( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000),
( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008);
#
select count(*)- 5 from t1 use index (s) where s < -000000000007;
select count(*)- 7 from t1 use index (s) where s <= -000000000007;
select count(*)- 2 from t1 use index (s) where s = -000000000007;
select count(*)- 5 from t1 use index (s) where s >= -000000000007;
select count(*)- 3 from t1 use index (s) where s > -000000000007;
#
select count(*)- 4 from t1 use index (t) where t < -0000061.00003;
select count(*)- 5 from t1 use index (t) where t <= -0000061.00003;
select count(*)- 1 from t1 use index (t) where t = -0000061.00003;
select count(*)- 6 from t1 use index (t) where t >= -0000061.00003;
select count(*)- 5 from t1 use index (t) where t > -0000061.00003;
#
select count(*)- 2 from t1 use index (u) where u < 000000000061;
select count(*)- 4 from t1 use index (u) where u <= 000000000061;
select count(*)- 2 from t1 use index (u) where u = 000000000061;
select count(*)- 8 from t1 use index (u) where u >= 000000000061;
select count(*)- 6 from t1 use index (u) where u > 000000000061;
#
select count(*)- 5 from t1 use index (v) where v < 0000965.00042;
select count(*)- 6 from t1 use index (v) where v <= 0000965.00042;
select count(*)- 1 from t1 use index (v) where v = 0000965.00042;
select count(*)- 5 from t1 use index (v) where v >= 0000965.00042;
select count(*)- 4 from t1 use index (v) where v > 0000965.00042;
drop table t1;
# bug#7798
create table t1(a int primary key, b int not null, index(b));
insert into t1 values (1,1), (2,2);
......
......@@ -2520,6 +2520,22 @@ call bug6029()|
drop procedure bug6029|
drop table t3|
#
# BUG#8540: Local variable overrides an alias
#
--disable_warnings
drop procedure if exists bug8540|
--enable_warnings
create procedure bug8540()
begin
declare x int default 1;
select x as y, x+0 as z;
end|
call bug8540()|
drop procedure bug8540|
#
# Some "real" examples
......
......@@ -24,6 +24,28 @@
#include <trigger_definitions.h>
#include <NdbSqlUtil.hpp>
#ifndef my_decimal_h
// sql/my_decimal.h requires many more sql/*.h new to ndb
// for now, copy the bit we need TODO proper fix
#define DECIMAL_MAX_LENGTH ((8 * 9) - 8)
#ifndef NOT_FIXED_DEC
#define NOT_FIXED_DEC 31
#endif
C_MODE_START
extern int decimal_bin_size(int, int);
C_MODE_END
inline int my_decimal_get_binary_size(uint precision, uint scale)
{
return decimal_bin_size((int)precision, (int)scale);
}
#endif
#define DTIMAP(x, y, z) \
{ DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 }
......@@ -264,7 +286,10 @@ public:
ExtBigunsigned = NdbSqlUtil::Type::Bigunsigned,
ExtFloat = NdbSqlUtil::Type::Float,
ExtDouble = NdbSqlUtil::Type::Double,
ExtOlddecimal = NdbSqlUtil::Type::Olddecimal,
ExtOlddecimalunsigned = NdbSqlUtil::Type::Olddecimalunsigned,
ExtDecimal = NdbSqlUtil::Type::Decimal,
ExtDecimalunsigned = NdbSqlUtil::Type::Decimalunsigned,
ExtChar = NdbSqlUtil::Type::Char,
ExtVarchar = NdbSqlUtil::Type::Varchar,
ExtBinary = NdbSqlUtil::Type::Binary,
......@@ -345,9 +370,31 @@ public:
AttributeSize = DictTabInfo::a64Bit;
AttributeArraySize = AttributeExtLength;
break;
case DictTabInfo::ExtOlddecimal:
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize =
(1 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) *
AttributeExtLength;
break;
case DictTabInfo::ExtOlddecimalunsigned:
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize =
(0 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) *
AttributeExtLength;
break;
case DictTabInfo::ExtDecimal:
// not yet implemented anywhere
return false;
case DictTabInfo::ExtDecimalunsigned:
{
// copy from Field_new_decimal ctor
uint precision = AttributeExtPrecision;
uint scale = AttributeExtScale;
if (precision > DECIMAL_MAX_LENGTH || scale >= NOT_FIXED_DEC)
precision = DECIMAL_MAX_LENGTH;
uint bin_size = my_decimal_get_binary_size(precision, scale);
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = bin_size * AttributeExtLength;
}
break;
case DictTabInfo::ExtChar:
case DictTabInfo::ExtBinary:
AttributeSize = DictTabInfo::an8Bit;
......
......@@ -48,7 +48,7 @@
#define NDB_TYPE_BIGUNSIGNED 10
#define NDB_TYPE_FLOAT 11
#define NDB_TYPE_DOUBLE 12
#define NDB_TYPE_DECIMAL 13 /* not used */
#define NDB_TYPE_OLDDECIMAL 13
#define NDB_TYPE_CHAR 14
#define NDB_TYPE_VARCHAR 15
#define NDB_TYPE_BINARY 16
......@@ -63,7 +63,10 @@
#define NDB_TYPE_TIME 25
#define NDB_TYPE_YEAR 26
#define NDB_TYPE_TIMESTAMP 27
#define NDB_TYPE_OLDDECIMALUNSIGNED 28
#define NDB_TYPE_DECIMAL 29
#define NDB_TYPE_DECIMALUNSIGNED 30
#define NDB_TYPE_MAX 28
#define NDB_TYPE_MAX 31
#endif
......@@ -184,7 +184,10 @@ public:
Bigunsigned = NDB_TYPE_BIGUNSIGNED, ///< 64 Bit. 8 byte signed integer, can be used in array
Float = NDB_TYPE_FLOAT, ///< 32-bit float. 4 bytes float, can be used in array
Double = NDB_TYPE_DOUBLE, ///< 64-bit float. 8 byte float, can be used in array
Decimal = NDB_TYPE_DECIMAL, ///< Precision, Scale are applicable
Olddecimal = NDB_TYPE_OLDDECIMAL, ///< MySQL < 5.0 signed decimal, Precision, Scale
Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED,
Decimal = NDB_TYPE_DECIMAL, ///< MySQL >= 5.0 signed decimal, Precision, Scale
Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED,
Char = NDB_TYPE_CHAR, ///< Len. A fixed array of 1-byte chars
Varchar = NDB_TYPE_VARCHAR, ///< Length bytes: 1, Max: 255
Binary = NDB_TYPE_BINARY, ///< Len
......@@ -248,13 +251,13 @@ public:
/**
* Get precision of column.
* @note Only applicable for builtin type Decimal
* @note Only applicable for decimal types
*/
int getPrecision() const;
/**
* Get scale of column.
* @note Only applicable for builtin type Decimal
* @note Only applicable for decimal types
*/
int getScale() const;
......@@ -372,13 +375,13 @@ public:
/**
* Set precision of column.
* @note Only applicable for builtin type Decimal
* @note Only applicable for decimal types
*/
void setPrecision(int);
/**
* Set scale of column.
* @note Only applicable for builtin type Decimal
* @note Only applicable for decimal types
*/
void setScale(int);
......
......@@ -97,12 +97,11 @@ public:
/**
* Constructor
*/
TransporterRegistry(NdbMgmHandle mgm_handle=NULL,
void * callback = 0 ,
TransporterRegistry(void * callback = 0 ,
unsigned maxTransporters = MAX_NTRANSPORTERS,
unsigned sizeOfLongSignalMemory = 100);
void set_mgm_handle(NdbMgmHandle h) { m_mgm_handle = h; };
void set_mgm_handle(NdbMgmHandle h);
NdbMgmHandle get_mgm_handle(void) { return m_mgm_handle; };
bool init(NodeId localNodeId);
......
......@@ -80,7 +80,7 @@ public:
Bigunsigned = NDB_TYPE_BIGUNSIGNED,
Float = NDB_TYPE_FLOAT,
Double = NDB_TYPE_DOUBLE,
Decimal = NDB_TYPE_DECIMAL,
Olddecimal = NDB_TYPE_OLDDECIMAL,
Char = NDB_TYPE_CHAR,
Varchar = NDB_TYPE_VARCHAR,
Binary = NDB_TYPE_BINARY,
......@@ -94,7 +94,10 @@ public:
Longvarbinary = NDB_TYPE_LONG_VARBINARY,
Time = NDB_TYPE_TIME,
Year = NDB_TYPE_YEAR,
Timestamp = NDB_TYPE_TIMESTAMP
Timestamp = NDB_TYPE_TIMESTAMP,
Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED,
Decimal = NDB_TYPE_DECIMAL,
Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED
};
Enum m_typeId; // redundant
Cmp* m_cmp; // comparison method
......@@ -130,6 +133,11 @@ public:
*/
static int strnxfrm_bug7284(CHARSET_INFO* cs, unsigned char* dst, unsigned dstLen, const unsigned char*src, unsigned srcLen);
/**
* Compare decimal numbers.
*/
static int cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n);
private:
/**
* List of all types. Must match Type::Enum.
......@@ -150,7 +158,7 @@ private:
static Cmp cmpBigunsigned;
static Cmp cmpFloat;
static Cmp cmpDouble;
static Cmp cmpDecimal;
static Cmp cmpOlddecimal;
static Cmp cmpChar;
static Cmp cmpVarchar;
static Cmp cmpBinary;
......@@ -165,6 +173,9 @@ private:
static Cmp cmpTime;
static Cmp cmpYear;
static Cmp cmpTimestamp;
static Cmp cmpOlddecimalunsigned;
static Cmp cmpDecimal;
static Cmp cmpDecimalunsigned;
};
#endif
......@@ -170,6 +170,35 @@ IPCConfig::configureTransporters(Uint32 nodeId,
DBUG_ENTER("IPCConfig::configureTransporters");
/**
* Iterate over all MGM's an construct a connectstring
* create mgm_handle and give it to the Transporter Registry
*/
{
const char *separator= "";
BaseString connect_string;
ndb_mgm_configuration_iterator iter(config, CFG_SECTION_NODE);
for(iter.first(); iter.valid(); iter.next())
{
Uint32 type;
if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue;
if(type != NODE_TYPE_MGM) continue;
const char* hostname;
Uint32 port;
if(iter.get(CFG_NODE_HOST, &hostname)) continue;
if( strlen(hostname) == 0 ) continue;
if(iter.get(CFG_MGM_PORT, &port)) continue;
connect_string.appfmt("%s%s:port",separator,hostname,port);
separator= ",";
}
NdbMgmHandle h= ndb_mgm_create_handle();
if ( h && connect_string.length() > 0 )
{
ndb_mgm_set_connectstring(h,connect_string.c_str());
tr.set_mgm_handle(h);
}
}
Uint32 noOfTransportersCreated= 0;
ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION);
......
......@@ -71,15 +71,14 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
DBUG_RETURN(0);
}
TransporterRegistry::TransporterRegistry(NdbMgmHandle mgm_handle,
void * callback,
TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters,
unsigned sizeOfLongSignalMemory) {
nodeIdSpecified = false;
maxTransporters = _maxTransporters;
sendCounter = 1;
m_mgm_handle = mgm_handle;
m_mgm_handle= 0;
callbackObj=callback;
......@@ -114,6 +113,27 @@ TransporterRegistry::TransporterRegistry(NdbMgmHandle mgm_handle,
theOSEJunkSocketRecv = 0;
}
void TransporterRegistry::set_mgm_handle(NdbMgmHandle h)
{
DBUG_ENTER("TransporterRegistry::set_mgm_handle");
if (m_mgm_handle)
ndb_mgm_destroy_handle(&m_mgm_handle);
m_mgm_handle= h;
#ifndef DBUG_OFF
if (h)
{
char buf[256];
DBUG_PRINT("info",("handle set with connectstring: %s",
ndb_mgm_get_connectstring(h,buf, sizeof(buf))));
}
else
{
DBUG_PRINT("info",("handle set to NULL"));
}
#endif
DBUG_VOID_RETURN;
};
TransporterRegistry::~TransporterRegistry() {
removeAll();
......@@ -134,6 +154,8 @@ TransporterRegistry::~TransporterRegistry() {
theOSEReceiver = 0;
}
#endif
if (m_mgm_handle)
ndb_mgm_destroy_handle(&m_mgm_handle);
}
void
......@@ -1211,40 +1233,32 @@ TransporterRegistry::start_clients_thread()
switch(performStates[nodeId]){
case CONNECTING:
if(!t->isConnected() && !t->isServer) {
int result= 0;
bool connected= false;
/**
* First, we try to connect (if we have a port number).
*/
if (t->get_s_port())
result= t->connect_client();
connected= t->connect_client();
if (result<0 && t->get_s_port()!=0)
g_eventLogger.warning("Error while trying to make connection "
"(Node %u to %u via port %u) "
"error: %d. Retrying...",
t->getRemoteNodeId(),
t->getLocalNodeId(),
t->get_s_port());
/**
* If dynamic, get the port for connecting from the management server
*/
if(t->get_s_port() <= 0) { // Port is dynamic
if( !connected && t->get_s_port() <= 0) { // Port is dynamic
int server_port= 0;
struct ndb_mgm_reply mgm_reply;
int res;
int res= -1;
if(!ndb_mgm_is_connected(m_mgm_handle))
if(ndb_mgm_connect(m_mgm_handle, 0, 0, 0)<0)
ndbout_c("Failed to reconnect to management server");
res= ndb_mgm_get_connection_int_parameter(m_mgm_handle,
t->getRemoteNodeId(),
t->getLocalNodeId(),
CFG_CONNECTION_SERVER_PORT,
&server_port,
&mgm_reply);
else
res=
ndb_mgm_get_connection_int_parameter(m_mgm_handle,
t->getRemoteNodeId(),
t->getLocalNodeId(),
CFG_CONNECTION_SERVER_PORT,
&server_port,
&mgm_reply);
DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)",
server_port,t->getRemoteNodeId(),
t->getLocalNodeId(),res));
......
......@@ -77,117 +77,129 @@ NdbSqlUtil::char_like(const char* s1, unsigned n1,
const NdbSqlUtil::Type
NdbSqlUtil::m_typeList[] = {
{
{ // 0
Type::Undefined,
NULL
},
{
{ // 1
Type::Tinyint,
cmpTinyint
},
{
{ // 2
Type::Tinyunsigned,
cmpTinyunsigned
},
{
{ // 3
Type::Smallint,
cmpSmallint
},
{
{ // 4
Type::Smallunsigned,
cmpSmallunsigned
},
{
{ // 5
Type::Mediumint,
cmpMediumint
},
{
{ // 6
Type::Mediumunsigned,
cmpMediumunsigned
},
{
{ // 7
Type::Int,
cmpInt
},
{
{ // 8
Type::Unsigned,
cmpUnsigned
},
{
{ // 9
Type::Bigint,
cmpBigint
},
{
{ // 10
Type::Bigunsigned,
cmpBigunsigned
},
{
{ // 11
Type::Float,
cmpFloat
},
{
{ // 12
Type::Double,
cmpDouble
},
{
Type::Decimal,
NULL // cmpDecimal
{ // 13
Type::Olddecimal,
cmpOlddecimal
},
{
{ // 14
Type::Char,
cmpChar
},
{
{ // 15
Type::Varchar,
cmpVarchar
},
{
{ // 16
Type::Binary,
cmpBinary
},
{
{ // 17
Type::Varbinary,
cmpVarbinary
},
{
{ // 18
Type::Datetime,
cmpDatetime
},
{
{ // 19
Type::Date,
cmpDate
},
{
{ // 20
Type::Blob,
NULL // cmpBlob
},
{
{ // 21
Type::Text,
NULL // cmpText
},
{
{ // 22
Type::Bit,
NULL // cmpBit
},
{
{ // 23
Type::Longvarchar,
cmpLongvarchar
},
{
{ // 24
Type::Longvarbinary,
cmpLongvarbinary
},
{
{ // 25
Type::Time,
cmpTime
},
{
{ // 26
Type::Year,
cmpYear
},
{
{ // 27
Type::Timestamp,
cmpTimestamp
},
{ // 28
Type::Olddecimalunsigned,
cmpOlddecimalunsigned
},
{ // 29
Type::Decimal,
cmpDecimal
},
{ // 30
Type::Decimalunsigned,
cmpDecimalunsigned
}
};
......@@ -430,14 +442,83 @@ NdbSqlUtil::cmpDouble(const void* info, const void* p1, unsigned n1, const void*
return CmpUnknown;
}
// not used by MySQL or NDB
int
NdbSqlUtil::cmpDecimal(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
NdbSqlUtil::cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n)
{
assert(false);
int sgn = +1;
unsigned i = 0;
while (i < n) {
int c1 = s1[i];
int c2 = s2[i];
if (c1 == c2) {
if (c1 == '-')
sgn = -1;
} else if (c1 == '-') {
return -1;
} else if (c2 == '-') {
return +1;
} else if (c1 < c2) {
return -1 * sgn;
} else {
return +1 * sgn;
}
i++;
}
return 0;
}
int
NdbSqlUtil::cmpOlddecimal(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
if (full) {
assert(n1 == n2);
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
return cmp_olddecimal(v1, v2, n1);
}
return CmpUnknown;
}
int
NdbSqlUtil::cmpOlddecimalunsigned(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
if (full) {
assert(n1 == n2);
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
return cmp_olddecimal(v1, v2, n1);
}
return CmpUnknown;
}
int
NdbSqlUtil::cmpDecimal(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
// compare as binary strings
unsigned n = (n1 <= n2 ? n1 : n2);
int k = memcmp(v1, v2, n);
if (k == 0) {
k = (full ? n1 : n) - n2;
}
return k < 0 ? -1 : k > 0 ? +1 : full ? 0 : CmpUnknown;
}
int
NdbSqlUtil::cmpDecimalunsigned(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
// compare as binary strings
unsigned n = (n1 <= n2 ? n1 : n2);
int k = memcmp(v1, v2, n);
if (k == 0) {
k = (full ? n1 : n) - n2;
}
return k < 0 ? -1 : k > 0 ? +1 : full ? 0 : CmpUnknown;
}
int
NdbSqlUtil::cmpChar(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
......
......@@ -92,10 +92,6 @@ int main(int argc, char** argv)
}
}
globalTransporterRegistry.set_mgm_handle(theConfig
->get_config_retriever()
->get_mgmHandle());
#ifndef NDB_WIN32
for(pid_t child = fork(); child != 0; child = fork()){
/**
......
......@@ -576,7 +576,7 @@ MgmtSrvr::start(BaseString &error_string)
}
}
theFacade= TransporterFacade::theFacadeInstance
= new TransporterFacade(m_config_retriever->get_mgmHandle());
= new TransporterFacade();
if(theFacade == 0) {
DEBUG("MgmtSrvr.cpp: theFacade is NULL.");
......
......@@ -84,7 +84,9 @@ NdbTransaction* Ndb::doConnect(Uint32 tConNode)
} else if (TretCode != 0) {
tAnyAlive= 1;
}//if
DBUG_PRINT("info",("tried node %d TretCode %d", tNode, TretCode));
DBUG_PRINT("info",("tried node %d, TretCode %d, error code %d, %s",
tNode, TretCode, getNdbError().code,
getNdbError().message));
}
}
else // just do a regular round robin
......
......@@ -948,8 +948,17 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col)
case NdbDictionary::Column::Double:
out << "Double";
break;
case NdbDictionary::Column::Olddecimal:
out << "Olddecimal(" << col.getPrecision() << "," << col.getScale() << ")";
break;
case NdbDictionary::Column::Olddecimalunsigned:
out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")";
break;
case NdbDictionary::Column::Decimal:
out << "Decimal(" << col.getScale() << "," << col.getPrecision() << ")";
out << "Decimal(" << col.getPrecision() << "," << col.getScale() << ")";
break;
case NdbDictionary::Column::Decimalunsigned:
out << "Decimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")";
break;
case NdbDictionary::Column::Char:
out << "Char(" << col.getLength() << ";" << csname << ")";
......
......@@ -109,7 +109,10 @@ NdbColumnImpl::init(Type t)
m_length = 1;
m_cs = NULL;
break;
case Olddecimal:
case Olddecimalunsigned:
case Decimal:
case Decimalunsigned:
m_precision = 10;
m_scale = 0;
m_length = 1;
......
......@@ -178,7 +178,8 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
return out;
}
uint length = r.getColumn()->getLength();
const NdbDictionary::Column* c = r.getColumn();
uint length = c->getLength();
if (length > 1)
out << "[";
......@@ -237,6 +238,22 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
case NdbDictionary::Column::Double:
out << r.double_value();
break;
case NdbDictionary::Column::Olddecimal:
{
short len = 1 + c->getPrecision() + (c->getScale() > 0);
out.print("%.*s", len, r.aRef());
}
break;
case NdbDictionary::Column::Olddecimalunsigned:
{
short len = 0 + c->getPrecision() + (c->getScale() > 0);
out.print("%.*s", len, r.aRef());
}
break;
case NdbDictionary::Column::Decimal:
case NdbDictionary::Column::Decimalunsigned:
goto unknown; // TODO
break;
// for dates cut-and-paste from field.cc
case NdbDictionary::Column::Datetime:
{
......@@ -346,6 +363,7 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
j = length;
}
break;
unknown:
default: /* no print functions for the rest, just print type */
out << (int) r.getType();
j = length;
......
......@@ -1420,14 +1420,18 @@ Remark: Sets TC Connect pointer.
int
NdbTransaction::receiveTCSEIZEREF(NdbApiSignal* aSignal)
{
DBUG_ENTER("NdbTransaction::receiveTCSEIZEREF");
if (theStatus != Connecting)
{
return -1;
DBUG_RETURN(-1);
} else
{
theStatus = ConnectFailure;
theNdb->theError.code = aSignal->readData(2);
return 0;
DBUG_PRINT("info",("error code %d, %s",
theNdb->getNdbError().code,
theNdb->getNdbError().message));
DBUG_RETURN(0);
}
}//NdbTransaction::receiveTCSEIZEREF()
......
......@@ -466,8 +466,7 @@ void TransporterFacade::threadMainReceive(void)
theTransporterRegistry->stopReceiving();
}
TransporterFacade::TransporterFacade(NdbMgmHandle mgm_handle) :
m_mgm_handle(mgm_handle),
TransporterFacade::TransporterFacade() :
theTransporterRegistry(0),
theStopReceive(0),
theSendThread(NULL),
......@@ -496,7 +495,7 @@ bool
TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
{
theOwnId = nodeId;
theTransporterRegistry = new TransporterRegistry(m_mgm_handle,this);
theTransporterRegistry = new TransporterRegistry(this);
const int res = IPCConfig::configureTransporters(nodeId,
* props,
......
......@@ -47,7 +47,7 @@ extern "C" {
class TransporterFacade
{
public:
TransporterFacade(NdbMgmHandle mgm_handle);
TransporterFacade();
virtual ~TransporterFacade();
bool init(Uint32, const ndb_mgm_configuration *);
......@@ -133,7 +133,6 @@ private:
bool isConnected(NodeId aNodeId);
void doStop();
NdbMgmHandle m_mgm_handle;
TransporterRegistry* theTransporterRegistry;
SocketServer m_socket_server;
int sendPerformedLastInterval;
......
......@@ -284,7 +284,7 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
m_transporter_facade=
TransporterFacade::theFacadeInstance=
new TransporterFacade(m_config_retriever->get_mgmHandle());
new TransporterFacade();
DBUG_VOID_RETURN;
}
......
......@@ -567,7 +567,10 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
case NdbDictionary::Column::Unsigned:
return UnSigned;
case NdbDictionary::Column::Float:
case NdbDictionary::Column::Olddecimal:
case NdbDictionary::Column::Olddecimalunsigned:
case NdbDictionary::Column::Decimal:
case NdbDictionary::Column::Decimalunsigned:
case NdbDictionary::Column::Double:
return Float;
case NdbDictionary::Column::Char:
......
......@@ -145,7 +145,10 @@ HugoCalculator::calcValue(int record,
case NdbDictionary::Column::Bigunsigned:
case NdbDictionary::Column::Float:
case NdbDictionary::Column::Double:
case NdbDictionary::Column::Olddecimal:
case NdbDictionary::Column::Olddecimalunsigned:
case NdbDictionary::Column::Decimal:
case NdbDictionary::Column::Decimalunsigned:
case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Datetime:
case NdbDictionary::Column::Time:
......
......@@ -44,9 +44,14 @@ BackupConsumer::create_table_string(const TableS & table,
case NdbDictionary::Column::Float:
pos += sprintf(buf+pos, "%s", "float");
break;
case NdbDictionary::Column::Olddecimal:
case NdbDictionary::Column::Decimal:
pos += sprintf(buf+pos, "%s", "decimal");
break;
case NdbDictionary::Column::Olddecimalunsigned:
case NdbDictionary::Column::Decimalunsigned:
pos += sprintf(buf+pos, "%s", "decimal unsigned");
break;
case NdbDictionary::Column::Char:
pos += sprintf(buf+pos, "%s", "char");
break;
......
......@@ -602,7 +602,7 @@ innobase_mysql_tmpfile(void)
{
char filename[FN_REFLEN];
int fd2 = -1;
File fd = create_temp_file(filename, NullS, "ib",
File fd = create_temp_file(filename, mysql_tmpdir, "ib",
#ifdef __WIN__
O_BINARY | O_TRUNC | O_SEQUENTIAL |
O_TEMPORARY | O_SHORT_LIVED |
......
......@@ -445,7 +445,6 @@ bool ha_ndbcluster::get_error_message(int error,
static inline bool ndb_supported_type(enum_field_types type)
{
switch (type) {
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG:
......@@ -453,6 +452,8 @@ static inline bool ndb_supported_type(enum_field_types type)
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_DATE:
......@@ -3337,10 +3338,6 @@ static int create_ndb_column(NDBCOL &col,
const enum enum_field_types mysql_type= field->real_type();
switch (mysql_type) {
// Numeric types
case MYSQL_TYPE_DECIMAL:
col.setType(NDBCOL::Char);
col.setLength(field->pack_length());
break;
case MYSQL_TYPE_TINY:
if (field->flags & UNSIGNED_FLAG)
col.setType(NDBCOL::Tinyunsigned);
......@@ -3384,6 +3381,44 @@ static int create_ndb_column(NDBCOL &col,
col.setType(NDBCOL::Double);
col.setLength(1);
break;
case MYSQL_TYPE_DECIMAL:
{
Field_decimal *f= (Field_decimal*)field;
uint precision= f->pack_length();
uint scale= f->decimals();
if (field->flags & UNSIGNED_FLAG)
{
col.setType(NDBCOL::Olddecimalunsigned);
precision-= (scale > 0);
}
else
{
col.setType(NDBCOL::Olddecimal);
precision-= 1 + (scale > 0);
}
col.setPrecision(precision);
col.setScale(scale);
col.setLength(1);
}
break;
case MYSQL_TYPE_NEWDECIMAL:
{
Field_new_decimal *f= (Field_new_decimal*)field;
uint precision= f->field_length;
uint scale= f->decimals();
if (field->flags & UNSIGNED_FLAG)
{
col.setType(NDBCOL::Decimalunsigned);
}
else
{
col.setType(NDBCOL::Decimal);
}
col.setPrecision(precision);
col.setScale(scale);
col.setLength(1);
}
break;
// Date types
case MYSQL_TYPE_DATETIME:
col.setType(NDBCOL::Datetime);
......
......@@ -471,7 +471,10 @@ class Item_splocal : public Item
{
Item *it= this_item();
it->set_name(m_name.str, m_name.length, system_charset_info);
if (name)
it->set_name(name, strlen(name), system_charset_info);
else
it->set_name(m_name.str, m_name.length, system_charset_info);
it->make_field(field);
}
......
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