| 1 |
# BUG #13511949 - NDB_RESTORE --PRINT-LOG DOES NOT PRODUCE VALID SQL |
| 2 |
|
| 3 |
--echo BUG #13511949 |
| 4 |
--echo "NDB_RESTORE --PRINT-LOG DOES NOT PRODUCE VALID SQL" |
| 5 |
|
| 6 |
-- source include/have_ndb.inc |
| 7 |
-- source have_ndb_error_insert.inc |
| 8 |
-- source suite/ndb/include/backup_restore_setup.inc |
| 9 |
|
| 10 |
create table t1 |
| 11 |
(id1 int unsigned not null, |
| 12 |
id2 int unsigned not null, |
| 13 |
id3 char(10), |
| 14 |
id4 varchar(10), |
| 15 |
id5 binary(10), |
| 16 |
id6 varbinary(10), |
| 17 |
id7 datetime, |
| 18 |
id8 date, |
| 19 |
id9 time, |
| 20 |
primary key(id1,id2) |
| 21 |
)engine=ndbcluster; |
| 22 |
|
| 23 |
create table t2 |
| 24 |
(id1 int primary key |
| 25 |
)engine=ndbcluster; |
| 26 |
|
| 27 |
#Introduce error to ensure that backup halts |
| 28 |
--exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT |
| 29 |
#Start backup with wait started so test does not wait indefinitely |
| 30 |
--exec $NDB_MGM -e "start backup wait started" >> $NDB_TOOLS_OUTPUT |
| 31 |
|
| 32 |
--echo "Logged queries:" |
| 33 |
insert into t1 values(1,1,'abc','def','ghi','jkl','2016-05-25 12:42:45','2016-05-25','12:42:45'); |
| 34 |
update t1 set id5='def' where id1<2 and id2=1; |
| 35 |
update t1 set id3='mno' where id1=1 and id2>0; |
| 36 |
delete from t1 where id1 is not null and id4 like 'd%'; |
| 37 |
|
| 38 |
#Remove error previously introduced |
| 39 |
--exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT |
| 40 |
#Retrieve backup ID |
| 41 |
--source include/ndb_backup_id.inc |
| 42 |
|
| 43 |
#Check if backup is complete. The table will be dropped |
| 44 |
#only when the backup is complete. Thus, the test attempts |
| 45 |
#to drop the table at intervals of 1 second and eventually |
| 46 |
#times out after 60 such intervals if the backup is not |
| 47 |
#yet completed |
| 48 |
--disable_warnings |
| 49 |
let $mysql_errno=1; |
| 50 |
let $i=60; |
| 51 |
while ($mysql_errno) |
| 52 |
{ |
| 53 |
sleep 1; |
| 54 |
dec $i; |
| 55 |
if (!$i) |
| 56 |
{ |
| 57 |
--die Timeout while wating for backup to complete; |
| 58 |
} |
| 59 |
--error 0,1051 |
| 60 |
drop table t2; |
| 61 |
} |
| 62 |
--enable_warnings |
| 63 |
--echo |
| 64 |
--echo "Restore with --print-sql-log option" |
| 65 |
--let ndb_restore_opts= --print-sql-log --verbose=0 |
| 66 |
--exec $NDB_RESTORE $ndb_restore_opts -b $the_backup_id -n 1 $NDB_BACKUPS-$the_backup_id |
| 67 |
--exec $NDB_RESTORE $ndb_restore_opts -b $the_backup_id -n 2 $NDB_BACKUPS-$the_backup_id |
| 68 |
|
| 69 |
drop table t1; |
| 70 |
--disable_warnings |
| 71 |
drop table if exists t2; |
| 72 |
--enable_warnings |
| 73 |
|
| 74 |
#Case with hidden PK where --print-sql-log option is not allowed |
| 75 |
--echo |
| 76 |
--echo "No primary key declared" |
| 77 |
create table t3 |
| 78 |
(id1 int, |
| 79 |
id2 int |
| 80 |
)engine=ndbcluster; |
| 81 |
|
| 82 |
create table t4 |
| 83 |
(id1 int primary key |
| 84 |
)engine=ndbcluster; |
| 85 |
|
| 86 |
#Introduce error to ensure that backup halts |
| 87 |
--exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT |
| 88 |
#Start backup with wait started so test does not wait indefinitely |
| 89 |
--exec $NDB_MGM -e "start backup wait started" >> $NDB_TOOLS_OUTPUT |
| 90 |
|
| 91 |
--echo "Logged queries:" |
| 92 |
insert into t3 values(1,2); |
| 93 |
insert into t3 values(2,3); |
| 94 |
update t3 set id2=5 where id1=1; |
| 95 |
delete from t3; |
| 96 |
|
| 97 |
#Remove error previously introduced |
| 98 |
--exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT |
| 99 |
--disable_warnings |
| 100 |
#Check if backup is complete. The table will be dropped |
| 101 |
#only when the backup is complete. Thus, the test attempts |
| 102 |
#to drop the table at intervals of 1 second and eventually |
| 103 |
#times out after 60 such intervals if the backup is not |
| 104 |
#yet completed |
| 105 |
let $mysql_errno=1; |
| 106 |
let $i=60; |
| 107 |
while ($mysql_errno) |
| 108 |
{ |
| 109 |
sleep 1; |
| 110 |
dec $i; |
| 111 |
if (!$i) |
| 112 |
{ |
| 113 |
--die Timeout while wating for backup to complete; |
| 114 |
} |
| 115 |
--error 0,1051 |
| 116 |
drop table t4; |
| 117 |
} |
| 118 |
--enable_warnings |
| 119 |
#Retrieve backup ID |
| 120 |
--source include/ndb_backup_id.inc |
| 121 |
--echo |
| 122 |
--echo "Restore with --print-sql-log option" |
| 123 |
--let ndb_restore_opts= --print-sql-log --verbose=0 |
| 124 |
|
| 125 |
# Masking timestamp from the restore output with 'X' to avoid tests |
| 126 |
# running on different dates give 'Result content mismatch'. |
| 127 |
--replace_regex /[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*/XXXX-XX-XX XX:XX:XX/ |
| 128 |
--error 1 |
| 129 |
--exec $NDB_RESTORE $ndb_restore_opts -b $the_backup_id -n 1 $NDB_BACKUPS-$the_backup_id 2>&1 |
| 130 |
|
| 131 |
drop table t3; |
| 132 |
--disable_warnings |
| 133 |
drop table if exists t4; |
| 134 |
--enable_warnings |
| 135 |
|
| 136 |
#Case where both --print-sql-log and --print-log options are passed |
| 137 |
--echo |
| 138 |
create table t5 |
| 139 |
(id1 int primary key, |
| 140 |
id2 int |
| 141 |
)engine=ndbcluster; |
| 142 |
|
| 143 |
create table t6 |
| 144 |
(id1 int primary key |
| 145 |
)engine=ndbcluster; |
| 146 |
#Introduce error to ensure that backup halts |
| 147 |
--exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT |
| 148 |
#Start backup with wait started so test does not wait indefinitely |
| 149 |
--exec $NDB_MGM -e "start backup wait started" >> $NDB_TOOLS_OUTPUT |
| 150 |
|
| 151 |
--echo "Logged queries:" |
| 152 |
insert into t5 values(1000,2000); |
| 153 |
update t5 set id2=5000 where id1=1000; |
| 154 |
delete from t5; |
| 155 |
|
| 156 |
#Remove error previously introduced |
| 157 |
--exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT |
| 158 |
#Check if backup is complete. The table will be dropped |
| 159 |
#only when the backup is complete. Thus, the test attempts |
| 160 |
#to drop the table at intervals of 1 second and eventually |
| 161 |
#times out after 60 such intervals if the backup is not |
| 162 |
#yet completed |
| 163 |
--disable_warnings |
| 164 |
let $mysql_errno=1; |
| 165 |
let $i=60; |
| 166 |
while ($mysql_errno) |
| 167 |
{ |
| 168 |
sleep 1; |
| 169 |
dec $i; |
| 170 |
if (!$i) |
| 171 |
{ |
| 172 |
--die Timeout while wating for backup to complete; |
| 173 |
} |
| 174 |
--error 0,1051 |
| 175 |
drop table t6; |
| 176 |
} |
| 177 |
--enable_warnings |
| 178 |
#Retrieve backup ID |
| 179 |
--source include/ndb_backup_id.inc |
| 180 |
--echo |
| 181 |
--echo "Restore with --print-sql-log and --print-log options" |
| 182 |
--let ndb_restore_opts= --print-sql-log --print-log --verbose=0 |
| 183 |
|
| 184 |
# Masking timestamp from the restore output with 'X' to avoid tests |
| 185 |
# running on different dates give 'Result content mismatch'. |
| 186 |
--replace_regex /[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*/XXXX-XX-XX XX:XX:XX/ |
| 187 |
--error 1 |
| 188 |
--exec $NDB_RESTORE $ndb_restore_opts -b $the_backup_id -n 1 $NDB_BACKUPS-$the_backup_id 2>&1 |
| 189 |
|
| 190 |
drop table t5; |
| 191 |
--disable_warnings |
| 192 |
drop table if exists t6; |
| 193 |
--enable_warnings |
| 194 |
|
| 195 |
#Case where table contains column of type blob |
| 196 |
--echo |
| 197 |
--echo "Table contains column of type blob" |
| 198 |
create table t7 |
| 199 |
(id1 int primary key, |
| 200 |
id2 blob |
| 201 |
)engine=ndbcluster; |
| 202 |
|
| 203 |
create table t8 |
| 204 |
(id1 int primary key |
| 205 |
)engine=ndbcluster; |
| 206 |
|
| 207 |
#Introduce error to ensure that backup halts |
| 208 |
--exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT |
| 209 |
#Start backup with wait started so test does not wait indefinitely |
| 210 |
--exec $NDB_MGM -e "start backup wait started" >> $NDB_TOOLS_OUTPUT |
| 211 |
|
| 212 |
--echo "Logged queries:" |
| 213 |
insert into t7 values(1,'a'); |
| 214 |
|
| 215 |
#Remove error previously introduced |
| 216 |
--exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT |
| 217 |
--disable_warnings |
| 218 |
#Check if backup is complete. The table will be dropped |
| 219 |
#only when the backup is complete. Thus, the test attempts |
| 220 |
#to drop the table at intervals of 1 second and eventually |
| 221 |
#times out after 60 such intervals if the backup is not |
| 222 |
#yet completed |
| 223 |
let $mysql_errno=1; |
| 224 |
let $i=60; |
| 225 |
while ($mysql_errno) |
| 226 |
{ |
| 227 |
sleep 1; |
| 228 |
dec $i; |
| 229 |
if (!$i) |
| 230 |
{ |
| 231 |
--die Timeout while wating for backup to complete; |
| 232 |
} |
| 233 |
--error 0,1051 |
| 234 |
drop table t8; |
| 235 |
} |
| 236 |
--enable_warnings |
| 237 |
#Retrieve backup ID |
| 238 |
--source include/ndb_backup_id.inc |
| 239 |
--echo |
| 240 |
--echo "Restore with --print-sql-log option" |
| 241 |
--let ndb_restore_opts= --print-sql-log --verbose=0 |
| 242 |
|
| 243 |
# Masking timestamp from the restore output with 'X' to avoid tests |
| 244 |
# running on different dates give 'Result content mismatch'. |
| 245 |
--replace_regex /[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*/XXXX-XX-XX XX:XX:XX/ |
| 246 |
--error 1 |
| 247 |
--exec $NDB_RESTORE $ndb_restore_opts -b $the_backup_id -n 1 $NDB_BACKUPS-$the_backup_id 2>&1 |
| 248 |
|
| 249 |
drop table t7; |
| 250 |
--disable_warnings |
| 251 |
drop table if exists t8; |
| 252 |
--enable_warnings |
| 253 |
|
| 254 |
--source suite/ndb/include/backup_restore_cleanup.inc |
| 255 |
--remove_file $NDB_TOOLS_OUTPUT |