| 1 |
-- source include/have_ndb.inc |
| 2 |
-- source suite/ndb/include/backup_restore_setup.inc |
| 3 |
|
| 4 |
# |
| 5 |
# Test BigInt [un]signed behaviours wrt offset remapping |
| 6 |
# |
| 7 |
# 2^64 = 18446744073709551616 |
| 8 |
# 2^63 = 9223372036854775808 |
| 9 |
# |
| 10 |
# Unsigned : 0 ... 18446744073709551615 |
| 11 |
# Signed : -9223372036854775808 ... 9223372036854775807 |
| 12 |
# |
| 13 |
|
| 14 |
create table t1 (kbu bigint unsigned, |
| 15 |
kbs bigint, |
| 16 |
dbu_low bigint unsigned, |
| 17 |
dbu_hi bigint unsigned, |
| 18 |
dbs_low bigint, |
| 19 |
dbs_hi bigint, |
| 20 |
d int, |
| 21 |
t text, |
| 22 |
primary key(kbu, kbs)) |
| 23 |
engine = ndb; |
| 24 |
|
| 25 |
insert into t1 values |
| 26 |
(10, 10, 0, 18446744073709551606, -9223372036854775808, 9223372036854775798, 10, repeat("10", 1000)), |
| 27 |
(11, 11, 1, 18446744073709551607, -9223372036854775807, 9223372036854775799, 11, repeat("11", 1000)), |
| 28 |
(12, 12, 2, 18446744073709551608, -9223372036854775806, 9223372036854775800, 12, repeat("12", 1000)), |
| 29 |
(13, 13, 3, 18446744073709551609, -9223372036854775805, 9223372036854775801, 13, repeat("13", 1000)), |
| 30 |
(14, 14, 4, 18446744073709551610, -9223372036854775804, 9223372036854775802, 14, repeat("14", 1000)), |
| 31 |
(15, 15, 5, 18446744073709551611, -9223372036854775803, 9223372036854775803, 15, repeat("15", 1000)), |
| 32 |
(16, 16, 6, 18446744073709551612, -9223372036854775802, 9223372036854775804, 16, repeat("16", 1000)), |
| 33 |
(17, 17, 7, 18446744073709551613, -9223372036854775801, 9223372036854775805, 17, repeat("17", 1000)), |
| 34 |
(18, 18, 8, 18446744073709551614, -9223372036854775800, 9223372036854775806, 18, repeat("18", 1000)), |
| 35 |
(19, 19, 9, 18446744073709551615, -9223372036854775799, 9223372036854775807, 19, repeat("19", 1000)); |
| 36 |
|
| 37 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 38 |
|
| 39 |
--echo Create a table with NULL-value columns |
| 40 |
create table t2( |
| 41 |
col1 int unsigned not null primary key, |
| 42 |
col2 int unsigned DEFAULT NULL) |
| 43 |
charset = utf8mb4 engine=ndbcluster; |
| 44 |
|
| 45 |
insert into t2 values(1, 1), (2,2), (3,NULL), (4,4), (5,5); |
| 46 |
|
| 47 |
--echo Run backup |
| 48 |
--source include/ndb_backup.inc |
| 49 |
|
| 50 |
--echo Restore with no key offsets + 0 + 0 |
| 51 |
--let remap_args = -x test.t1.kbu:offset:0 |
| 52 |
--let remap_args = $remap_args -x test.t1.kbs:offset:0 |
| 53 |
|
| 54 |
--echo Remapping a column having NULL values with an offset. |
| 55 |
--echo NULL values will be preserved. |
| 56 |
--let remap_args = $remap_args -x test.t2.col2:offset:10 |
| 57 |
|
| 58 |
truncate test.t1; |
| 59 |
truncate table t2; |
| 60 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 61 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 62 |
|
| 63 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 64 |
select * from t2 order by col1; |
| 65 |
|
| 66 |
--echo Restore with small overlapping key offset + 5 |
| 67 |
--let remap_args = -x test.t1.kbu:offset:5 |
| 68 |
--let remap_args = $remap_args -x test.t1.kbs:offset:5 |
| 69 |
|
| 70 |
truncate test.t1; |
| 71 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 72 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 73 |
|
| 74 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 75 |
|
| 76 |
--echo Restore with larger gap key offset + 20 |
| 77 |
--let remap_args = -x test.t1.kbu:offset:20 |
| 78 |
--let remap_args = $remap_args -x test.t1.kbs:offset:20 |
| 79 |
truncate test.t1; |
| 80 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 81 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 82 |
|
| 83 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 84 |
|
| 85 |
--echo Restore with low data values + max offset (9223372036854775807) |
| 86 |
--let remap_args = -x test.t1.dbu_low:offset:9223372036854775807 |
| 87 |
--let remap_args = $remap_args -x test.t1.dbs_low:offset:9223372036854775807 |
| 88 |
truncate test.t1; |
| 89 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 90 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 91 |
|
| 92 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 93 |
|
| 94 |
--echo Restore with key offset + 30 and low data offset + 110 |
| 95 |
--let remap_args = -x test.t1.kbu:offset:30 |
| 96 |
--let remap_args = $remap_args -x test.t1.kbs:offset:30 |
| 97 |
--let remap_args = $remap_args -x test.t1.dbu_low:offset:110 |
| 98 |
--let remap_args = $remap_args -x test.t1.dbs_low:offset:110 |
| 99 |
truncate test.t1; |
| 100 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 101 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 102 |
|
| 103 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 104 |
|
| 105 |
--echo Restore with high data values - max offset (-9223372036854775808) |
| 106 |
--let remap_args = -x test.t1.dbu_hi:offset:-9223372036854775808 |
| 107 |
--let remap_args = $remap_args -x test.t1.dbs_hi:offset:-9223372036854775808 |
| 108 |
truncate test.t1; |
| 109 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 110 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 111 |
|
| 112 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 113 |
|
| 114 |
--echo Restore with key offset - 10 |
| 115 |
--let remap_args = -x test.t1.kbu:offset:-10 |
| 116 |
--let remap_args = $remap_args -x test.t1.kbs:offset:-10 |
| 117 |
truncate test.t1; |
| 118 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 119 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 120 |
|
| 121 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 122 |
|
| 123 |
--echo Restore with max positive key offset kbu + 9223372036854775807 kbs + 9223372036854775807-19 |
| 124 |
--let remap_args = -x test.t1.kbu:offset:9223372036854775807 |
| 125 |
--let remap_args = $remap_args -x test.t1.kbs:offset:9223372036854775788 |
| 126 |
truncate test.t1; |
| 127 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 128 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 129 |
|
| 130 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 131 |
|
| 132 |
--echo Restore with max negative key offset kbu -10 kbs -9223372036854775808 |
| 133 |
--let remap_args = -x test.t1.kbu:offset:-10 |
| 134 |
--let remap_args = $remap_args -x test.t1.kbs:offset:-9223372036854775808 |
| 135 |
truncate test.t1; |
| 136 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 137 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 138 |
|
| 139 |
select kbu, kbs, dbu_low, dbu_hi, dbs_low, dbs_hi, d, sha1(t) from test.t1 order by kbu; |
| 140 |
|
| 141 |
drop table test.t1; |
| 142 |
drop table test.t2; |
| 143 |
|
| 144 |
|
| 145 |
# |
| 146 |
# Test Int [un]signed behaviours wrt offset remapping |
| 147 |
# |
| 148 |
# 2^32 = 4294967296 |
| 149 |
# 2^31 = 2147483648 |
| 150 |
# |
| 151 |
# Unsigned : 0 ... 4294967295 |
| 152 |
# Signed : -2147483648 ... 2147483647 |
| 153 |
# |
| 154 |
# |
| 155 |
|
| 156 |
create table t1 (kiu int unsigned, |
| 157 |
kis int, |
| 158 |
diu_low int unsigned, |
| 159 |
diu_hi int unsigned, |
| 160 |
dis_low int, |
| 161 |
dis_hi int, |
| 162 |
d int, |
| 163 |
t text, |
| 164 |
primary key(kiu, kis)) |
| 165 |
engine = ndb; |
| 166 |
|
| 167 |
insert into t1 values |
| 168 |
(10, 10, 0, 4294967286, -2147483648, 2147483638, 10, repeat("10", 1000)), |
| 169 |
(11, 11, 1, 4294967287, -2147483647, 2147483639, 11, repeat("11", 1000)), |
| 170 |
(12, 12, 2, 4294967288, -2147483646, 2147483640, 12, repeat("12", 1000)), |
| 171 |
(13, 13, 3, 4294967289, -2147483645, 2147483641, 13, repeat("13", 1000)), |
| 172 |
(14, 14, 4, 4294967290, -2147483644, 2147483642, 14, repeat("14", 1000)), |
| 173 |
(15, 15, 5, 4294967291, -2147483643, 2147483643, 15, repeat("15", 1000)), |
| 174 |
(16, 16, 6, 4294967292, -2147483642, 2147483644, 16, repeat("16", 1000)), |
| 175 |
(17, 17, 7, 4294967293, -2147483641, 2147483645, 17, repeat("17", 1000)), |
| 176 |
(18, 18, 8, 4294967294, -2147483640, 2147483646, 18, repeat("18", 1000)), |
| 177 |
(19, 19, 9, 4294967295, -2147483639, 2147483647, 19, repeat("19", 1000)); |
| 178 |
|
| 179 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 180 |
|
| 181 |
--echo Run backup |
| 182 |
--source include/ndb_backup.inc |
| 183 |
|
| 184 |
--echo Restore with no key offsets + 0 + 0 |
| 185 |
--let remap_args = -x test.t1.kiu:offset:0 |
| 186 |
--let remap_args = $remap_args -x test.t1.kis:offset:0 |
| 187 |
truncate test.t1; |
| 188 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 189 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 190 |
|
| 191 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 192 |
|
| 193 |
--echo Restore with small overlapping key offset + 5 |
| 194 |
--let remap_args = -x test.t1.kiu:offset:5 |
| 195 |
--let remap_args = $remap_args -x test.t1.kis:offset:5 |
| 196 |
|
| 197 |
truncate test.t1; |
| 198 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 199 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 200 |
|
| 201 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 202 |
|
| 203 |
--echo Restore with larger gap key offset + 20 |
| 204 |
--let remap_args = -x test.t1.kiu:offset:20 |
| 205 |
--let remap_args = $remap_args -x test.t1.kis:offset:20 |
| 206 |
truncate test.t1; |
| 207 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 208 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 209 |
|
| 210 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 211 |
|
| 212 |
--echo Restore with low data values + max offset (2147483647) |
| 213 |
--let remap_args = -x test.t1.diu_low:offset:2147483647 |
| 214 |
--let remap_args = $remap_args -x test.t1.dis_low:offset:2147483647 |
| 215 |
truncate test.t1; |
| 216 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 217 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 218 |
|
| 219 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 220 |
|
| 221 |
--echo Restore with key offset + 30 and low data offset + 110 |
| 222 |
--let remap_args = -x test.t1.kiu:offset:30 |
| 223 |
--let remap_args = $remap_args -x test.t1.kis:offset:30 |
| 224 |
--let remap_args = $remap_args -x test.t1.diu_low:offset:110 |
| 225 |
--let remap_args = $remap_args -x test.t1.dis_low:offset:110 |
| 226 |
truncate test.t1; |
| 227 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 228 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 229 |
|
| 230 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 231 |
|
| 232 |
--echo Restore with high data values - max offset (-2147483648) |
| 233 |
--let remap_args = -x test.t1.diu_hi:offset:-2147483648 |
| 234 |
--let remap_args = $remap_args -x test.t1.dis_hi:offset:-2147483648 |
| 235 |
truncate test.t1; |
| 236 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 237 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 238 |
|
| 239 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 240 |
|
| 241 |
--echo Restore with key offset - 10 |
| 242 |
--let remap_args = -x test.t1.kiu:offset:-10 |
| 243 |
--let remap_args = $remap_args -x test.t1.kis:offset:-10 |
| 244 |
truncate test.t1; |
| 245 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 246 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 247 |
|
| 248 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 249 |
|
| 250 |
--echo Restore with max positive key offset kiu + 2147483647 kis + 2147483647-19 |
| 251 |
--let remap_args = -x test.t1.kiu:offset:2147483647 |
| 252 |
--let remap_args = $remap_args -x test.t1.kis:offset:2147483628 |
| 253 |
truncate test.t1; |
| 254 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 255 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 256 |
|
| 257 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 258 |
|
| 259 |
--echo Restore with max negative key offset kiu -10 kis -2147483648 |
| 260 |
--let remap_args = -x test.t1.kiu:offset:-10 |
| 261 |
--let remap_args = $remap_args -x test.t1.kis:offset:-2147483648 |
| 262 |
truncate test.t1; |
| 263 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 264 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $remap_args $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 265 |
|
| 266 |
select kiu, kis, diu_low, diu_hi, dis_low, dis_hi, d, sha1(t) from test.t1 order by kiu; |
| 267 |
|
| 268 |
drop table test.t1; |
| 269 |
|
| 270 |
--source suite/ndb/include/backup_restore_cleanup.inc |
| 271 |
--remove_file $NDB_TOOLS_OUTPUT |
| 272 |
|