Commit bd49cdd2 authored by tomas@poseidon.mysql.com's avatar tomas@poseidon.mysql.com

Merge poseidon.mysql.com:/home/tomas/mysql-5.0-telco-gca-ndb_restore

into  poseidon.mysql.com:/home/tomas/mysql-5.1-telco-gca-ndb_restore
parents f6845d14 a42d10a3
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults $ndb_restore_opts -b $the_backup_id -n 1 $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id $ndb_restore_filter > $MYSQLTEST_VARDIR/tmp/tmp.dat
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults $ndb_restore_opts -b $the_backup_id -n 2 $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id $ndb_restore_filter >> $MYSQLTEST_VARDIR/tmp/tmp.dat
--exec sort $MYSQLTEST_VARDIR/tmp/tmp.dat
--exec rm -f $MYSQLTEST_VARDIR/tmp/tmp.dat
--let ndb_restore_opts=
--let ndb_restore_filter=
use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
create table t1
(pk int key
,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64)
,b1 TINYINT, b2 TINYINT UNSIGNED
,c1 SMALLINT, c2 SMALLINT UNSIGNED
,d1 INT, d2 INT UNSIGNED
,e1 BIGINT, e2 BIGINT UNSIGNED
,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY
,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY
,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255)
,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000)
) engine ndb;
insert into t1 values
(1
,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001
,127, 255
,32767, 65535
,2147483647, 4294967295
,9223372036854775807, 18446744073709551615
,'1','12345678901234567890123456789012','123456789'
,'1','12345678901234567890123456789012','123456789'
,0x12,0x123456789abcdef0, 0x012345
,0x12,0x123456789abcdef0, 0x00123450
);
insert into t1 values
(2
,0, 0, 0, 0, 0
,-128, 0
,-32768, 0
,-2147483648, 0
,-9223372036854775808, 0
,'','',''
,'','',''
,0x0,0x0,0x0
,0x0,0x0,0x0
);
insert into t1 values
(3
,NULL,NULL,NULL,NULL,NULL
,NULL,NULL
,NULL,NULL
,NULL,NULL
,NULL,NULL
,NULL,NULL,NULL
,NULL,NULL,NULL
,NULL,NULL,NULL
,NULL,NULL,NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
DELETE FROM test.backup_info;
LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
SELECT @the_backup_id:=backup_id FROM test.backup_info;
@the_backup_id:=backup_id
<the_backup_id>
DROP TABLE test.backup_info;
1;0x1;0x17;0x789A;0x789ABCDE;0xFEDC0001;127;255;32767;65535;2147483647;4294967295;9223372036854775807;18446744073709551615;1;12345678901234567890123456789012;123456789;1;12345678901234567890123456789012;123456789;0x12;0x123456789ABCDEF0;0x012345;0x12;0x123456789ABCDEF0;0x00123450
2;0x0;0x0;0x0;0x0;0x0;-128;0;-32768;0;-2147483648;0;-9223372036854775808;0;;;;;;;0x0;0x0;0x0;0x0;0x0;0x0
3;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N
1,0x1,0x17,0x789A,0x789ABCDE,0xFEDC0001,127,255,32767,65535,2147483647,4294967295,9223372036854775807,18446744073709551615,'1','12345678901234567890123456789012','123456789','1','12345678901234567890123456789012','123456789',0x12,0x123456789ABCDEF0,0x012345,0x12,0x123456789ABCDEF0,0x00123450
2,0x0,0x0,0x0,0x0,0x0,-128,0,-32768,0,-2147483648,0,-9223372036854775808,0,'','','','','','',0x0,0x0,0x0,0x0,0x0,0x0
3,,,,,,,,,,,,,,,,,,,,,,,,,
drop table t1;
create table t1
(pk int key
,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY
,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY
,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255)
,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000)
) engine ndb;
insert into t1 values
(1
,'1','12345678901234567890123456789012','123456789 '
,'1 ','12345678901234567890123456789012 ','123456789 '
,0x20,0x123456789abcdef020, 0x012345000020
,0x1200000020,0x123456789abcdef000000020, 0x00123450000020
);
create table t2 (pk int key, a int) engine ndb;
create table t3 (pk int key, a int) engine ndb;
create table t4 (pk int key, a int) engine ndb;
insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15);
insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25);
insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35);
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
DELETE FROM test.backup_info;
LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
SELECT @the_backup_id:=backup_id FROM test.backup_info;
@the_backup_id:=backup_id
<the_backup_id>
DROP TABLE test.backup_info;
'1';'1';'12345678901234567890123456789012';'123456789';'1';'12345678901234567890123456789012';'123456789';'0x20';'0x123456789ABCDEF020';'0x012345000020';'0x1200000020';'0x123456789ABCDEF000000020';'0x00123450000020'
t1
--
1;1;12345678901234567890123456789012;123456789;1;12345678901234567890123456789012;123456789;0x20;0x123456789ABCDEF020;0x012345000020;0x1200000020;0x123456789ABCDEF000000020;0x00123450000020
t2
--
1;11
2;12
3;13
4;14
5;15
t3
--
1;21
2;22
3;23
4;24
5;25
t4
--
1;31
2;32
3;33
4;34
5;35
drop table t1;
drop table t2;
drop table t3;
drop table t4;
-- source include/have_ndb.inc
-- source include/ndb_default_cluster.inc
-- source include/not_embedded.inc
--disable_warnings
use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
--enable_warnings
# basic datatypes
create table t1
(pk int key
,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64)
,b1 TINYINT, b2 TINYINT UNSIGNED
,c1 SMALLINT, c2 SMALLINT UNSIGNED
,d1 INT, d2 INT UNSIGNED
,e1 BIGINT, e2 BIGINT UNSIGNED
,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY
,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY
,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255)
,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000)
) engine ndb;
# max values
insert into t1 values
(1
,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001
,127, 255
,32767, 65535
,2147483647, 4294967295
,9223372036854775807, 18446744073709551615
,'1','12345678901234567890123456789012','123456789'
,'1','12345678901234567890123456789012','123456789'
,0x12,0x123456789abcdef0, 0x012345
,0x12,0x123456789abcdef0, 0x00123450
);
# min values
insert into t1 values
(2
,0, 0, 0, 0, 0
,-128, 0
,-32768, 0
,-2147483648, 0
,-9223372036854775808, 0
,'','',''
,'','',''
,0x0,0x0,0x0
,0x0,0x0,0x0
);
# null values
insert into t1 values
(3
,NULL,NULL,NULL,NULL,NULL
,NULL,NULL
,NULL,NULL
,NULL,NULL
,NULL,NULL
,NULL,NULL,NULL
,NULL,NULL,NULL
,NULL,NULL,NULL
,NULL,NULL,NULL
);
--source include/ndb_backup.inc
--let ndb_restore_filter=test t1
--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";"
--source include/ndb_backup_print.inc
--let ndb_restore_filter=test t1
--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by="," --fields-optionally-enclosed-by="'"
--source include/ndb_backup_print.inc
drop table t1;
# some binary char tests with trailing spaces
create table t1
(pk int key
,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY
,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY
,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255)
,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000)
) engine ndb;
insert into t1 values
(1
,'1','12345678901234567890123456789012','123456789 '
,'1 ','12345678901234567890123456789012 ','123456789 '
,0x20,0x123456789abcdef020, 0x012345000020
,0x1200000020,0x123456789abcdef000000020, 0x00123450000020
);
create table t2 (pk int key, a int) engine ndb;
create table t3 (pk int key, a int) engine ndb;
create table t4 (pk int key, a int) engine ndb;
insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15);
insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25);
insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35);
--source include/ndb_backup.inc
--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-enclosed-by="'" --fields-optionally-enclosed-by="X"
--let ndb_restore_filter=test t1
--source include/ndb_backup_print.inc
--exec rm -f $MYSQLTEST_VARDIR/tmp/t1.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t2.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t3.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t4.txt
--let ndb_restore_opts=--verbose=0 --print_data --hex --tab $MYSQLTEST_VARDIR/tmp --append
--let ndb_restore_filter=test
--source include/ndb_backup_print.inc
--let $message= t1
--source include/show_msg.inc
--exec sort $MYSQLTEST_VARDIR/tmp/t1.txt
--let $message= t2
--source include/show_msg.inc
--exec sort $MYSQLTEST_VARDIR/tmp/t2.txt
--let $message= t3
--source include/show_msg.inc
--exec sort $MYSQLTEST_VARDIR/tmp/t3.txt
--let $message= t4
--source include/show_msg.inc
--exec sort $MYSQLTEST_VARDIR/tmp/t4.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t1.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t2.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t3.txt
--exec rm -f $MYSQLTEST_VARDIR/tmp/t4.txt
# clean up
drop table t1;
drop table t2;
drop table t3;
drop table t4;
...@@ -409,6 +409,25 @@ NdbRecAttr::setUNDEFINED() ...@@ -409,6 +409,25 @@ NdbRecAttr::setUNDEFINED()
class NdbOut& operator <<(class NdbOut&, const NdbRecAttr &); class NdbOut& operator <<(class NdbOut&, const NdbRecAttr &);
class NdbRecordPrintFormat
{
public:
NdbRecordPrintFormat();
virtual ~NdbRecordPrintFormat();
const char *lines_terminated_by;
const char *fields_terminated_by;
const char *start_array_enclosure;
const char *end_array_enclosure;
const char *fields_enclosed_by;
const char *fields_optionally_enclosed_by;
const char *hex_prefix;
const char *null_string;
int hex_format;
};
NdbOut&
ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
const NdbRecordPrintFormat &f);
#endif // ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #endif // ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
#endif #endif
......
...@@ -36,6 +36,7 @@ class FileOutputStream : public OutputStream { ...@@ -36,6 +36,7 @@ class FileOutputStream : public OutputStream {
public: public:
FileOutputStream(FILE * file = stdout); FileOutputStream(FILE * file = stdout);
virtual ~FileOutputStream() {} virtual ~FileOutputStream() {}
FILE *getFile() { return f; }
int print(const char * fmt, ...); int print(const char * fmt, ...);
int println(const char * fmt, ...); int println(const char * fmt, ...);
......
...@@ -138,8 +138,24 @@ NdbRecAttr::receive_data(const Uint32 * data, Uint32 sz){ ...@@ -138,8 +138,24 @@ NdbRecAttr::receive_data(const Uint32 * data, Uint32 sz){
return false; return false;
} }
NdbRecordPrintFormat::NdbRecordPrintFormat()
{
fields_terminated_by= ";";
start_array_enclosure= "[";
end_array_enclosure= "]";
fields_enclosed_by= "";
fields_optionally_enclosed_by= "\"";
lines_terminated_by= "\n";
hex_prefix= "H'";
null_string= "[NULL]";
hex_format= 0;
}
NdbRecordPrintFormat::~NdbRecordPrintFormat() {};
static const NdbRecordPrintFormat default_print_format;
static void static void
ndbrecattr_print_string(NdbOut& out, const char *type, ndbrecattr_print_string(NdbOut& out, const NdbRecordPrintFormat &f,
const char *type, bool is_binary,
const char *aref, unsigned sz) const char *aref, unsigned sz)
{ {
const unsigned char* ref = (const unsigned char*)aref; const unsigned char* ref = (const unsigned char*)aref;
...@@ -148,6 +164,25 @@ ndbrecattr_print_string(NdbOut& out, const char *type, ...@@ -148,6 +164,25 @@ ndbrecattr_print_string(NdbOut& out, const char *type,
for (i=sz-1; i >= 0; i--) for (i=sz-1; i >= 0; i--)
if (ref[i] == 0) sz--; if (ref[i] == 0) sz--;
else break; else break;
if (!is_binary)
{
// trailing spaces are not printed
for (i=sz-1; i >= 0; i--)
if (ref[i] == 32) sz--;
else break;
}
if (is_binary && f.hex_format)
{
if (sz == 0)
{
out.print("0x0");
return;
}
out.print("0x");
for (len = 0; len < (int)sz; len++)
out.print("%02X", (int)ref[len]);
return;
}
if (sz == 0) return; // empty if (sz == 0) return; // empty
for (len=0; len < (int)sz && ref[i] != 0; len++) for (len=0; len < (int)sz && ref[i] != 0; len++)
...@@ -168,37 +203,56 @@ ndbrecattr_print_string(NdbOut& out, const char *type, ...@@ -168,37 +203,56 @@ ndbrecattr_print_string(NdbOut& out, const char *type,
for (i= len+1; ref[i] != 0; i++) for (i= len+1; ref[i] != 0; i++)
out.print("%u]",len-i); out.print("%u]",len-i);
assert((int)sz > i); assert((int)sz > i);
ndbrecattr_print_string(out,type,aref+i,sz-i); ndbrecattr_print_string(out,f,type,is_binary,aref+i,sz-i);
} }
} }
NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) NdbOut&
ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
const NdbRecordPrintFormat &f)
{ {
if (r.isNULL()) if (r.isNULL())
{ {
out << "[NULL]"; out << f.null_string;
return out; return out;
} }
const NdbDictionary::Column* c = r.getColumn(); const NdbDictionary::Column* c = r.getColumn();
uint length = c->getLength(); uint length = c->getLength();
if (length > 1)
out << "[";
for (Uint32 j = 0; j < length; j++)
{ {
if (j > 0) const char *fields_optionally_enclosed_by;
out << " "; if (f.fields_enclosed_by[0] == '\0')
fields_optionally_enclosed_by=
f.fields_optionally_enclosed_by;
else
fields_optionally_enclosed_by= "";
out << f.fields_enclosed_by;
Uint32 j;
switch(r.getType()){ switch(r.getType()){
case NdbDictionary::Column::Bigunsigned: case NdbDictionary::Column::Bigunsigned:
out << r.u_64_value(); out << r.u_64_value();
break; break;
case NdbDictionary::Column::Bit: case NdbDictionary::Column::Bit:
out << hex << "H'" << r.u_32_value() << dec; for (j = (length-1)/32 + 1; j > 0; j--)
if (*((Uint32*)r.aRef() + j - 1))
break;
if (j == 0)
{
out << "0x0";
break;
}
out << f.hex_prefix << "0x";
for (; j > 0; j--)
out.print("%X", *((Uint32*)r.aRef() + j - 1));
break; break;
case NdbDictionary::Column::Unsigned: case NdbDictionary::Column::Unsigned:
out << *((Uint32*)r.aRef() + j); if (length > 1)
out << f.start_array_enclosure;
out << *(Uint32*)r.aRef();
for (j = 1; j < length; j++)
out << " " << *((Uint32*)r.aRef() + j);
if (length > 1)
out << f.end_array_enclosure;
break; break;
case NdbDictionary::Column::Smallunsigned: case NdbDictionary::Column::Smallunsigned:
out << r.u_short_value(); out << r.u_short_value();
...@@ -219,25 +273,37 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) ...@@ -219,25 +273,37 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
out << (int) r.char_value(); out << (int) r.char_value();
break; break;
case NdbDictionary::Column::Binary: case NdbDictionary::Column::Binary:
if (!f.hex_format)
out << fields_optionally_enclosed_by;
j = r.get_size_in_bytes(); j = r.get_size_in_bytes();
ndbrecattr_print_string(out,"Binary", r.aRef(), j); ndbrecattr_print_string(out,f,"Binary", true, r.aRef(), j);
if (!f.hex_format)
out << fields_optionally_enclosed_by;
break; break;
case NdbDictionary::Column::Char: case NdbDictionary::Column::Char:
out << fields_optionally_enclosed_by;
j = r.get_size_in_bytes(); j = r.get_size_in_bytes();
ndbrecattr_print_string(out,"Char", r.aRef(), j); ndbrecattr_print_string(out,f,"Char", false, r.aRef(), j);
out << fields_optionally_enclosed_by;
break; break;
case NdbDictionary::Column::Varchar: case NdbDictionary::Column::Varchar:
{ {
out << fields_optionally_enclosed_by;
unsigned len = *(const unsigned char*)r.aRef(); unsigned len = *(const unsigned char*)r.aRef();
ndbrecattr_print_string(out,"Varchar", r.aRef()+1,len); ndbrecattr_print_string(out,f,"Varchar", false, r.aRef()+1,len);
j = length; j = length;
out << fields_optionally_enclosed_by;
} }
break; break;
case NdbDictionary::Column::Varbinary: case NdbDictionary::Column::Varbinary:
{ {
if (!f.hex_format)
out << fields_optionally_enclosed_by;
unsigned len = *(const unsigned char*)r.aRef(); unsigned len = *(const unsigned char*)r.aRef();
ndbrecattr_print_string(out,"Varbinary", r.aRef()+1,len); ndbrecattr_print_string(out,f,"Varbinary", true, r.aRef()+1,len);
j = length; j = length;
if (!f.hex_format)
out << fields_optionally_enclosed_by;
} }
break; break;
case NdbDictionary::Column::Float: case NdbDictionary::Column::Float:
...@@ -366,16 +432,28 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) ...@@ -366,16 +432,28 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
break; break;
case NdbDictionary::Column::Longvarchar: case NdbDictionary::Column::Longvarchar:
{ {
out << fields_optionally_enclosed_by;
unsigned len = uint2korr(r.aRef()); unsigned len = uint2korr(r.aRef());
ndbrecattr_print_string(out,"Longvarchar", r.aRef()+2,len); ndbrecattr_print_string(out,f,"Longvarchar", false, r.aRef()+2,len);
j = length; j = length;
out << fields_optionally_enclosed_by;
}
break;
case NdbDictionary::Column::Longvarbinary:
{
if (!f.hex_format)
out << fields_optionally_enclosed_by;
unsigned len = uint2korr(r.aRef());
ndbrecattr_print_string(out,f,"Longvarbinary", true, r.aRef()+2,len);
j = length;
if (!f.hex_format)
out << fields_optionally_enclosed_by;
} }
break; break;
case NdbDictionary::Column::Undefined: case NdbDictionary::Column::Undefined:
case NdbDictionary::Column::Mediumint: case NdbDictionary::Column::Mediumint:
case NdbDictionary::Column::Mediumunsigned: case NdbDictionary::Column::Mediumunsigned:
case NdbDictionary::Column::Longvarbinary:
unknown: unknown:
//default: /* no print functions for the rest, just print type */ //default: /* no print functions for the rest, just print type */
out << (int) r.getType(); out << (int) r.getType();
...@@ -384,16 +462,17 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) ...@@ -384,16 +462,17 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
out << " " << j << " times"; out << " " << j << " times";
break; break;
} }
} out << f.fields_enclosed_by;
if (length > 1)
{
out << "]";
} }
return out; return out;
} }
NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
{
return ndbrecattr_print_formatted(out, r, default_print_format);
}
Int64 Int64
NdbRecAttr::int64_value() const NdbRecAttr::int64_value() const
{ {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <NdbAutoPtr.hpp> #include <NdbAutoPtr.hpp>
#include "../../../../sql/ha_ndbcluster_tables.h" #include "../../../../sql/ha_ndbcluster_tables.h"
extern NdbRecordPrintFormat g_ndbrecord_print_format;
Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data
Uint32 Twiddle32(Uint32 in); // Byte shift 32-bit data Uint32 Twiddle32(Uint32 in); // Byte shift 32-bit data
...@@ -298,6 +299,7 @@ RestoreMetaData::markSysTables() ...@@ -298,6 +299,7 @@ RestoreMetaData::markSysTables()
Uint32 i; Uint32 i;
for (i = 0; i < getNoOfTables(); i++) { for (i = 0; i < getNoOfTables(); i++) {
TableS* table = allTables[i]; TableS* table = allTables[i];
table->m_local_id = i;
const char* tableName = table->getTableName(); const char* tableName = table->getTableName();
if ( // XXX should use type if ( // XXX should use type
strcmp(tableName, "SYSTAB_0") == 0 || strcmp(tableName, "SYSTAB_0") == 0 ||
...@@ -313,6 +315,7 @@ RestoreMetaData::markSysTables() ...@@ -313,6 +315,7 @@ RestoreMetaData::markSysTables()
strcmp(tableName, "cluster/def/" OLD_NDB_APPLY_TABLE) == 0 || strcmp(tableName, "cluster/def/" OLD_NDB_APPLY_TABLE) == 0 ||
strcmp(tableName, NDB_REP_DB "/def/" NDB_APPLY_TABLE) == 0 || strcmp(tableName, NDB_REP_DB "/def/" NDB_APPLY_TABLE) == 0 ||
strcmp(tableName, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE)== 0 ) strcmp(tableName, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE)== 0 )
table->isSysTable = true; table->isSysTable = true;
} }
for (i = 0; i < getNoOfTables(); i++) { for (i = 0; i < getNoOfTables(); i++) {
...@@ -330,6 +333,7 @@ RestoreMetaData::markSysTables() ...@@ -330,6 +333,7 @@ RestoreMetaData::markSysTables()
if (table->getTableId() == (Uint32) id1) { if (table->getTableId() == (Uint32) id1) {
if (table->isSysTable) if (table->isSysTable)
blobTable->isSysTable = true; blobTable->isSysTable = true;
blobTable->m_main_table = table;
break; break;
} }
} }
...@@ -427,6 +431,7 @@ TableS::TableS(Uint32 version, NdbTableImpl* tableImpl) ...@@ -427,6 +431,7 @@ TableS::TableS(Uint32 version, NdbTableImpl* tableImpl)
m_noOfRecords= 0; m_noOfRecords= 0;
backupVersion = version; backupVersion = version;
isSysTable = false; isSysTable = false;
m_main_table = NULL;
for (int i = 0; i < tableImpl->getNoOfColumns(); i++) for (int i = 0; i < tableImpl->getNoOfColumns(); i++)
createAttr(tableImpl->getColumn(i)); createAttr(tableImpl->getColumn(i));
...@@ -896,6 +901,7 @@ bool RestoreDataIterator::readFragmentHeader(int & ret, Uint32 *fragmentId) ...@@ -896,6 +901,7 @@ bool RestoreDataIterator::readFragmentHeader(int & ret, Uint32 *fragmentId)
return false; return false;
} }
info.setLevel(254);
info << "_____________________________________________________" << endl info << "_____________________________________________________" << endl
<< "Processing data in table: " << m_currentTable->getTableName() << "Processing data in table: " << m_currentTable->getTableName()
<< "(" << Header.TableId << ") fragment " << "(" << Header.TableId << ") fragment "
...@@ -1153,14 +1159,14 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){ ...@@ -1153,14 +1159,14 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){
if (data.null) if (data.null)
{ {
ndbout << "<NULL>"; ndbout << g_ndbrecord_print_format.null_string;
return ndbout; return ndbout;
} }
NdbRecAttr tmprec(0); NdbRecAttr tmprec(0);
tmprec.setup(desc.m_column, (char *)data.void_value); tmprec.setup(desc.m_column, 0);
tmprec.receive_data((Uint32*)data.void_value, data.size); tmprec.receive_data((Uint32*)data.void_value, data.size);
ndbout << tmprec; ndbrecattr_print_formatted(ndbout, tmprec, g_ndbrecord_print_format);
return ndbout; return ndbout;
} }
...@@ -1169,17 +1175,15 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){ ...@@ -1169,17 +1175,15 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){
NdbOut& NdbOut&
operator<<(NdbOut& ndbout, const TupleS& tuple) operator<<(NdbOut& ndbout, const TupleS& tuple)
{ {
ndbout << tuple.getTable()->getTableName() << "; ";
for (int i = 0; i < tuple.getNoOfAttributes(); i++) for (int i = 0; i < tuple.getNoOfAttributes(); i++)
{ {
if (i > 0)
ndbout << g_ndbrecord_print_format.fields_terminated_by;
AttributeData * attr_data = tuple.getData(i); AttributeData * attr_data = tuple.getData(i);
const AttributeDesc * attr_desc = tuple.getDesc(i); const AttributeDesc * attr_desc = tuple.getDesc(i);
const AttributeS attr = {attr_desc, *attr_data}; const AttributeS attr = {attr_desc, *attr_data};
debug << i << " " << attr_desc->m_column->getName(); debug << i << " " << attr_desc->m_column->getName();
ndbout << attr; ndbout << attr;
if (i != (tuple.getNoOfAttributes() - 1))
ndbout << delimiter << " ";
} // for } // for
return ndbout; return ndbout;
} }
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include <ndb_version.h> #include <ndb_version.h>
#include <version.h> #include <version.h>
static const char * delimiter = ";"; // Delimiter in file dump
const int FileNameLenC = 256; const int FileNameLenC = 256;
const int TableNameLenC = 256; const int TableNameLenC = 256;
const int AttrNameLenC = 256; const int AttrNameLenC = 256;
...@@ -142,6 +140,8 @@ class TableS { ...@@ -142,6 +140,8 @@ class TableS {
Uint64 m_max_auto_val; Uint64 m_max_auto_val;
bool isSysTable; bool isSysTable;
TableS *m_main_table;
Uint32 m_local_id;
Uint64 m_noOfRecords; Uint64 m_noOfRecords;
Vector<FragmentInfo *> m_fragmentInfo; Vector<FragmentInfo *> m_fragmentInfo;
...@@ -156,6 +156,9 @@ public: ...@@ -156,6 +156,9 @@ public:
Uint32 getTableId() const { Uint32 getTableId() const {
return m_dictTable->getTableId(); return m_dictTable->getTableId();
} }
Uint32 getLocalId() const {
return m_local_id;
}
Uint32 getNoOfRecords() const { Uint32 getNoOfRecords() const {
return m_noOfRecords; return m_noOfRecords;
} }
...@@ -239,6 +242,10 @@ public: ...@@ -239,6 +242,10 @@ public:
return isSysTable; return isSysTable;
} }
const TableS *getMainTable() const {
return m_main_table;
}
TableS& operator=(TableS& org) ; TableS& operator=(TableS& org) ;
}; // TableS; }; // TableS;
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "consumer_printer.hpp" #include "consumer_printer.hpp"
extern FilteredNdbOut info;
extern NdbRecordPrintFormat g_ndbrecord_print_format;
extern const char *tab_path;
bool bool
BackupPrinter::table(const TableS & tab) BackupPrinter::table(const TableS & tab)
...@@ -21,7 +24,8 @@ BackupPrinter::table(const TableS & tab) ...@@ -21,7 +24,8 @@ BackupPrinter::table(const TableS & tab)
if (m_print || m_print_meta) if (m_print || m_print_meta)
{ {
m_ndbout << tab; m_ndbout << tab;
ndbout_c("Successfully printed table: %s", tab.m_dictTable->getName()); info.setLevel(254);
info << "Successfully printed table: ", tab.m_dictTable->getName();
} }
return true; return true;
} }
...@@ -31,7 +35,14 @@ BackupPrinter::tuple(const TupleS & tup, Uint32 fragId) ...@@ -31,7 +35,14 @@ BackupPrinter::tuple(const TupleS & tup, Uint32 fragId)
{ {
m_dataCount++; m_dataCount++;
if (m_print || m_print_data) if (m_print || m_print_data)
m_ndbout << tup << endl; {
if (m_ndbout.m_out == info.m_out)
{
info.setLevel(254);
info << tup.getTable()->getTableName() << "; ";
}
m_ndbout << tup << g_ndbrecord_print_format.lines_terminated_by;
}
} }
void void
...@@ -47,9 +58,10 @@ BackupPrinter::endOfLogEntrys() ...@@ -47,9 +58,10 @@ BackupPrinter::endOfLogEntrys()
{ {
if (m_print || m_print_log) if (m_print || m_print_log)
{ {
ndbout << "Printed " << m_dataCount << " tuples and " info.setLevel(254);
<< m_logCount << " log entries" info << "Printed " << m_dataCount << " tuples and "
<< " to stdout." << endl; << m_logCount << " log entries"
<< " to stdout." << endl;
} }
} }
bool bool
......
This diff is collapsed.
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