Commit 7473c70b authored by unknown's avatar unknown
Browse files

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


BitKeeper/deleted/.del-ndb_backup.inc:
  Delete: mysql-test/include/ndb_backup.inc
storage/ndb/include/ndbapi/NdbRecAttr.hpp:
  Auto merged
storage/ndb/tools/restore/consumer_printer.cpp:
  Auto merged
storage/ndb/include/util/OutputStream.hpp:
  manual merge
storage/ndb/src/ndbapi/NdbRecAttr.cpp:
  manual merge
storage/ndb/tools/restore/Restore.cpp:
  manual merge
storage/ndb/tools/restore/Restore.hpp:
  manual merge
storage/ndb/tools/restore/restore_main.cpp:
  manual merge
parents 690b46cf 2d797068
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
--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=
+124 −0
Original line number Diff line number Diff line
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;
+140 −0
Original line number Diff line number Diff line
-- 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;
+19 −0
Original line number Diff line number Diff line
@@ -409,6 +409,25 @@ NdbRecAttr::setUNDEFINED()

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
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class FileOutputStream : public OutputStream {
public:
  FileOutputStream(FILE * file = stdout);
  virtual ~FileOutputStream() {}
  FILE *getFile() { return f; }

  int print(const char * fmt, ...);
  int println(const char * fmt, ...);
Loading