polardbxengine/mysql-test/suite/ndb/r/ndb_restore_conv_binary.result

702 lines
39 KiB
Plaintext

***********************
Test binary conversions
***********************
create table test.t1 (
a int unsigned primary key,
b binary(20),
c varbinary(200),
d varbinary(2000),
e blob,
f tinyblob,
g mediumblob,
h longblob
) engine=ndb;
insert into test.t1 values (1,
'1111111111', # binary
repeat('Pattern', 20), # varbinary
repeat('LongPattern', 100), # longvarbinary
repeat('Tartan', 4096), # blob
repeat('Tartan', 40), # tinyblob
repeat('Tartan', 4096), # mediumblob
repeat('Tartan', 4096));
insert into test.t1 select a+1, repeat(a+1, 10), c, d, e, f, g, h from test.t1;
insert into test.t1 select a+2, repeat(a+2, 10), c, d, e, f, g, h from test.t1;
insert into test.t1 select a+4, repeat(a+4, 10), c, d, e, f, g, h from test.t1;
Source data
select a,
hex(b),
sha1(c),
length(c),
sha1(d),
length(d),
sha1(e),
length(e),
sha1(f),
length(f),
sha1(g),
length(g),
sha1(h),
length(h) from test.t1 order by a;
a hex(b) sha1(c) length(c) sha1(d) length(d) sha1(e) length(e) sha1(f) length(f) sha1(g) length(g) sha1(h) length(h)
1 3131313131313131313100000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
2 3232323232323232323200000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
3 3333333333333333333300000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
4 3434343434343434343400000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
5 3535353535353535353500000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
6 3636363636363636363600000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
7 3737373737373737373700000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
8 3838383838383838383800000000000000000000 3779d4742af03e7363788e6e3258b49354b0b80d 140 b3347e38ec350725bc73c80f60d2727096c9a6a3 1100 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 b45dcdc72f779995c05640ed7baa8ee5602c560f 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576
Run backup
rename table test.t1 to test.t1_orig;
********************
Test type promotions
********************
Have one of each we are interested in to start with
Repeatedly 'shift left' onto wider types
longblob <- mediumblob <- blob <- longvarbinary <- tinyblob <- varbinary <- binary
create table test.t1 (
a int unsigned primary key,
b varbinary(20), # binary -> varbinary
c varbinary(2000), # varbinary -> longvarbinary
d blob, # longvarbinary -> blob
e mediumblob, # blob -> mediumblob
f blob, # tinyblob -> blob
g longblob, # mediumblob -> longblob
h longblob # longblob -> longblob
) engine=ndb;
# run restore
Expect no data differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where LEFT(o.b,10) != r.b or # ignore Binary padding
length(r.b) != 10 or
o.c != r.c or
o.d != r.d or
o.e != r.e or
o.f != r.f or
o.g != r.g or
o.h != r.h;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b varbinary(2000), # binary -> longvarbinary
c tinyblob, # varbinary -> tinyblob
d mediumblob, # longvarbinary -> mediumblob
e longblob, # blob -> longblob
f mediumblob, # tinyblob -> mediumblob
g longblob, # mediumblob -> longblob
h longblob # longblob -> longblob
) engine=ndb;
# run restore
Expect no data differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where LEFT(o.b,10) != r.b or # ignore Binary padding
length(r.b) != 10 or
o.c != r.c or
o.d != r.d or
o.e != r.e or
o.f != r.f or
o.g != r.g or
o.h != r.h;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b tinyblob, # binary -> tinyblob
c blob, # varbinary -> blob
d longblob, # longvarbinary -> longblob
e longblob, # blob -> longblob
f longblob, # tinyblob -> longblob
g longblob, # mediumblob -> longblob
h longblob # longblob -> longblob
) engine=ndb;
# run restore
Expect no data differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where LEFT(o.b,10) != r.b or # ignore Binary padding
length(r.b) != 10 or
o.c != r.c or
o.d != r.d or
o.e != r.e or
o.f != r.f or
o.g != r.g or
o.h != r.h;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b blob, # binary -> blob
c mediumblob, # varbinary -> mediumblob
d longblob, # longvarbinary -> longblob
e longblob, # blob -> longblob
f longblob, # tinyblob -> longblob
g longblob, # mediumblob -> longblob
h longblob # longblob -> longblob
) engine=ndb;
# run restore
Expect no data differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where LEFT(o.b,10) != r.b or # ignore Binary padding
length(r.b) != 10 or
o.c != r.c or
o.d != r.d or
o.e != r.e or
o.f != r.f or
o.g != r.g or
o.h != r.h;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b mediumblob, # binary -> mediumblob
c longblob, # varbinary -> longblob
d longblob, # longvarbinary -> longblob
e longblob, # blob -> longblob
f longblob, # tinyblob -> longblob
g longblob, # mediumblob -> longblob
h longblob # longblob -> longblob
) engine=ndb;
# run restore
Expect no data differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where LEFT(o.b,10) != r.b or # ignore Binary padding
length(r.b) != 10 or
o.c != r.c or
o.d != r.d or
o.e != r.e or
o.f != r.f or
o.g != r.g or
o.h != r.h;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b longblob, # binary -> longblob
c longblob, # varbinary -> longblob
d longblob, # longvarbinary -> longblob
e longblob, # blob -> longblob
f longblob, # tinyblob -> longblob
g longblob, # mediumblob -> longblob
h longblob # longblob -> longblob
) engine=ndb;
# run restore
Expect no data differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where LEFT(o.b,10) != r.b or # ignore Binary padding
length(r.b) != 10 or
o.c != r.c or
o.d != r.d or
o.e != r.e or
o.f != r.f or
o.g != r.g or
o.h != r.h;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
*******************
Test type demotions
*******************
Have one of each we are interested in to start with
Repeatedly 'shift right' onto smaller types
longblob -> mediumblob -> blob -> longvarbinary -> tinyblob -> varbinary -> binary
create table test.t1 (
a int unsigned primary key,
b binary(20), # binary -> binary
c binary(200), # varbinary -> binary
d tinyblob, # longvarbinary -> tinyblob
e varbinary(2000), # blob -> longvarbinary
f varbinary(200), # tinyblob -> varbinary
g blob, # mediumblob -> blob
h mediumblob # longblob -> mediumblob
) engine=ndb;
# run restore
Expect no unexpected differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where o.b != r.b # b as is
or o.c != left(r.c, 140)
or length(o.c) != 140 # c expanded to 200
or left(o.d, 255) != r.d # d truncated to 255
or left(o.e,2000) != r.e
or length(r.e) != 2000 # e truncated to 2000
or left(o.f,200) != r.f
or length(r.f) != 200 # f truncated to 200
or o.g != r.g # g as-is
or o.h != r.h # h as-is
;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
Warnings:
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
Warning 1265 Truncated value from TEXT field 'd'
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b binary(20), # binary -> binary
c binary(200), # varbinary -> binary
d varbinary(200), # longvarbinary -> varbinary
e tinyblob, # blob -> tinyblob
f binary(200), # tinyblob -> binary
g varbinary(2000), # mediumblob -> longvarbinary
h blob # longblob -> blob
) engine=ndb;
# run restore
Expect no unexpected differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where o.b != r.b # b as is
or o.c != left(r.c, 140)
or length(o.c) != 140 # c expanded to 200
or left(o.d, 200) != r.d # d truncated to 200
or left(o.e, 255) != r.e
or length(r.e) != 255 # e truncated to 255
or left(o.f, 200) != r.f
or length(r.f) != 200 # f truncated to 200
or left(o.g, 2000) != r.g
or length(r.g) != 2000 # g truncated to 2000
or o.h != r.h # h as-is
;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
Warnings:
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
Warning 1265 Truncated value from TEXT field 'e'
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b binary(20), # binary -> binary
c binary(200), # varbinary -> binary
d binary(200), # longvarbinary -> binary
e varbinary(200), # blob -> varbinary
f binary(200), # tinyblob -> binary
g tinyblob, # mediumblob -> tinyblob
h varbinary(2000) # longblob -> longvarbinary
) engine=ndb;
# run restore
Expect no unexpected differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where o.b != r.b # b as is
or o.c != left(r.c, 140)
or length(o.c) != 140 # c expanded to 200
or left(o.d, 200) != r.d # d truncated to 200
or left(o.e, 200) != r.e
or length(r.e) != 200 # e truncated to 200
or left(o.f, 200) != r.f
or length(r.f) != 200 # f truncated to 200
or left(o.g, 255) != r.g
or length(r.g) != 255 # g truncated to 255
or left(o.h, 2000) != r.h
or length(r.h) != 2000 # h truncated to 2000
;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
Warnings:
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
Warning 1265 Truncated value from TEXT field 'g'
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b binary(20), # binary -> binary
c binary(200), # varbinary -> binary
d binary(200), # longvarbinary -> binary
e binary(200), # blob -> binary
f binary(200), # tinyblob -> binary
g varbinary(200), # mediumblob -> varbinary
h tinyblob # longblob -> tinyblob
) engine=ndb;
# run restore
Expect no unexpected differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where o.b != r.b # b as is
or o.c != left(r.c, 140)
or length(o.c) != 140 # c expanded to 200
or left(o.d, 200) != r.d # d truncated to 200
or left(o.e, 200) != r.e
or length(r.e) != 200 # e truncated to 200
or left(o.f, 200) != r.f
or length(r.f) != 200 # f truncated to 200
or left(o.g, 200) != r.g
or length(r.g) != 200 # g truncated to 200
or left(o.h, 255) != r.h
or length(r.h) != 255 # h truncated to 255
;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
Warnings:
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
Warning 1265 Truncated value from TEXT field 'h'
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b binary(20), # binary -> binary
c binary(200), # varbinary -> binary
d binary(200), # longvarbinary -> binary
e binary(200), # blob -> binary
f binary(200), # tinyblob -> binary
g binary(200), # mediumblob -> binary
h varbinary(200) # longblob -> varbinary
) engine=ndb;
# run restore
Expect no unexpected differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where o.b != r.b # b as is
or o.c != left(r.c, 140)
or length(o.c) != 140 # c expanded to 200
or left(o.d, 200) != r.d # d truncated to 200
or left(o.e, 200) != r.e
or length(r.e) != 200 # e truncated to 200
or left(o.f, 200) != r.f
or length(r.f) != 200 # f truncated to 200
or left(o.g, 200) != r.g
or length(r.g) != 200 # g truncated to 200
or left(o.h, 200) != r.h
or length(r.h) != 200 # h truncated to 200
;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
create table test.t1 (
a int unsigned primary key,
b binary(20), # binary -> binary
c binary(200), # varbinary -> binary
d binary(200), # longvarbinary -> binary
e binary(200), # blob -> binary
f binary(200), # tinyblob -> binary
g binary(200), # mediumblob -> binary
h binary(200) # longblob -> binary
) engine=ndb;
# run restore
Expect no unexpected differences between orig and restored
select o.a, o.b, sha1(o.c), length(o.c), sha1(o.d), length(o.d), sha1(o.e), length(o.e), sha1(o.f), length(o.f), sha1(o.g), length(o.g), sha1(o.h), length(o.h),
r.a, r.b, sha1(r.c), length(r.c), sha1(r.d), length(r.d), sha1(r.e), length(r.e), sha1(r.f), length(r.f), sha1(r.g), length(r.g), sha1(r.h), length(r.h)
from t1_orig o join t1 r
on o.a = r.a
where o.b != r.b # b as is
or o.c != left(r.c, 140)
or length(o.c) != 140 # c expanded to 200
or left(o.d, 200) != r.d # d truncated to 200
or left(o.e, 200) != r.e
or length(r.e) != 200 # e truncated to 200
or left(o.f, 200) != r.f
or length(r.f) != 200 # f truncated to 200
or left(o.g, 200) != r.g
or length(r.g) != 200 # g truncated to 200
or left(o.h, 200) != r.h
or length(r.h) != 200 # h truncated to 200
;
a b sha1(o.c) length(o.c) sha1(o.d) length(o.d) sha1(o.e) length(o.e) sha1(o.f) length(o.f) sha1(o.g) length(o.g) sha1(o.h) length(o.h) a b sha1(r.c) length(r.c) sha1(r.d) length(r.d) sha1(r.e) length(r.e) sha1(r.f) length(r.f) sha1(r.g) length(r.g) sha1(r.h) length(r.h)
drop table test.t1;
drop table test.t1_orig;
********************************
Text to blob conversions
********************************
create table test.t2 (
a int unsigned primary key,
tinytext1 tinytext,
tinytext2 tinytext,
tinytext3 tinytext,
tinytext4 tinytext,
text1 text,
text2 text,
text3 text,
text4 text,
mediumtext1 mediumtext,
mediumtext2 mediumtext,
mediumtext3 mediumtext,
mediumtext4 mediumtext,
longtext1 longtext,
longtext2 longtext,
longtext3 longtext,
longtext4 longtext
) engine=ndb character set UTF8MB4;
insert into test.t2 values (1,
repeat('Tartan', 40), # tinytext
repeat('Tartan', 40),
repeat('Tartan', 40),
repeat('Tartan', 40),
repeat('Tartan', 4096), # text
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096), # mediumtext
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096), # longtext
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096));
insert into test.t2 values (0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
Source data
select a,
sha(tinytext1), sha(tinytext2), sha(tinytext3), sha(tinytext4),
length(tinytext1), length(tinytext2), length(tinytext3), length(tinytext4),
sha(text1), sha(text2), sha(text3), sha(text4),
length(text1), length(text2), length(text3), length(text4),
sha(mediumtext1), sha(mediumtext2), sha(mediumtext3), sha(mediumtext4),
length(mediumtext1), length(mediumtext2), length(mediumtext3), length(mediumtext4),
sha(longtext1), sha(longtext2), sha(longtext3), sha(longtext4),
length(longtext1), length(longtext2), length(longtext3), length(longtext4) from test.t2 order by a;
a sha(tinytext1) sha(tinytext2) sha(tinytext3) sha(tinytext4) length(tinytext1) length(tinytext2) length(tinytext3) length(tinytext4) sha(text1) sha(text2) sha(text3) sha(text4) length(text1) length(text2) length(text3) length(text4) sha(mediumtext1) sha(mediumtext2) sha(mediumtext3) sha(mediumtext4) length(mediumtext1) length(mediumtext2) length(mediumtext3) length(mediumtext4) sha(longtext1) sha(longtext2) sha(longtext3) sha(longtext4) length(longtext1) length(longtext2) length(longtext3) length(longtext4)
0 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 NULL NULL NULL NULL NULL NULL NULL
1 b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f 240 240 240 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 24576 24576 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 24576 24576 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 24576 24576 24576
Run backup
rename table test.t2 to test.t2_orig;
create table test.t2 (
a int unsigned primary key,
tinytext1 tinyblob, # tinytext -> tinyblob
tinytext2 blob, # tinytext -> blob
tinytext3 mediumblob, # tinytext -> mediumblob
tinytext4 longblob, # tinytext -> longblob
text1 tinyblob, # text -> tinyblob
text2 blob, # text -> blob
text3 mediumblob, # text -> mediumblob
text4 longblob, # text -> longblob
mediumtext1 tinyblob, # mediumtext -> tinyblob
mediumtext2 blob, # mediumtext -> blob
mediumtext3 mediumblob,# mediumtext -> mediumblob
mediumtext4 longblob, # mediumtext -> longblob
longtext1 tinyblob, # longtext -> tinyblob
longtext2 blob, # longtext -> blob
longtext3 mediumblob, # longtext -> mediumblob
longtext4 longblob # longtext -> longblob
) engine=ndb;
select count(*) from test.t2;
count(*)
2
select a,
sha(tinytext1), sha(tinytext2), sha(tinytext3), sha(tinytext4),
length(tinytext1), length(tinytext2), length(tinytext3), length(tinytext4),
sha(text1), sha(text2), sha(text3), sha(text4),
length(text1), length(text2), length(text3), length(text4),
sha(mediumtext1), sha(mediumtext2), sha(mediumtext3), sha(mediumtext4),
length(mediumtext1), length(mediumtext2), length(mediumtext3), length(mediumtext4),
sha(longtext1), sha(longtext2), sha(longtext3), sha(longtext4),
length(longtext1), length(longtext2), length(longtext3), length(longtext4) from test.t2 order by a;
a sha(tinytext1) sha(tinytext2) sha(tinytext3) sha(tinytext4) length(tinytext1) length(tinytext2) length(tinytext3) length(tinytext4) sha(text1) sha(text2) sha(text3) sha(text4) length(text1) length(text2) length(text3) length(text4) sha(mediumtext1) sha(mediumtext2) sha(mediumtext3) sha(mediumtext4) length(mediumtext1) length(mediumtext2) length(mediumtext3) length(mediumtext4) sha(longtext1) sha(longtext2) sha(longtext3) sha(longtext4) length(longtext1) length(longtext2) length(longtext3) length(longtext4)
0 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 NULL NULL NULL NULL NULL NULL NULL
1 b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f 240 240 240 240 6824e9d1a458a3ceb7fa93ad783746f7698f1ba8 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 255 24576 24576 24576 6824e9d1a458a3ceb7fa93ad783746f7698f1ba8 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 255 24576 24576 24576 6824e9d1a458a3ceb7fa93ad783746f7698f1ba8 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 255 24576 24576 24576
Warnings:
Warning 1265 Truncated value from TEXT field 'text1'
Warning 1265 Truncated value from TEXT field 'mediumtext1'
Warning 1265 Truncated value from TEXT field 'longtext1'
drop table test.t2;
drop table test.t2_orig;
********************************
Blob to text conversions
********************************
create table test.t2 (
a int unsigned primary key,
tinyblob1 tinyblob,
tinyblob2 tinyblob,
tinyblob3 tinyblob,
tinyblob4 tinyblob,
blob1 blob,
blob2 blob,
blob3 blob,
blob4 blob,
mediumblob1 mediumblob,
mediumblob2 mediumblob,
mediumblob3 mediumblob,
mediumblob4 mediumblob,
longblob1 longblob,
longblob2 longblob,
longblob3 longblob,
longblob4 longblob
) engine=ndb character set UTF8MB4;
insert into test.t2 values (1,
repeat('Tartan', 40), # tinyblob
repeat('Tartan', 40),
repeat('Tartan', 40),
repeat('Tartan', 40),
repeat('Tartan', 4096), # blob
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096), # mediumblob
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096), # longblob
repeat('Tartan', 4096),
repeat('Tartan', 4096),
repeat('Tartan', 4096));
insert into test.t2 values (0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
Source data
select a,
sha(tinyblob1), sha(tinyblob2), sha(tinyblob3), sha(tinyblob4),
length(tinyblob1), length(tinyblob2), length(tinyblob3), length(tinyblob4),
sha(blob1), sha(blob2), sha(blob3), sha(blob4),
length(blob1), length(blob2), length(blob3), length(blob4),
sha(mediumblob1), sha(mediumblob2), sha(mediumblob3), sha(mediumblob4),
length(mediumblob1), length(mediumblob2), length(mediumblob3), length(mediumblob4),
sha(longblob1), sha(longblob2), sha(longblob3), sha(longblob4),
length(longblob1), length(longblob2), length(longblob3), length(longblob4) from test.t2 order by a;
a sha(tinyblob1) sha(tinyblob2) sha(tinyblob3) sha(tinyblob4) length(tinyblob1) length(tinyblob2) length(tinyblob3) length(tinyblob4) sha(blob1) sha(blob2) sha(blob3) sha(blob4) length(blob1) length(blob2) length(blob3) length(blob4) sha(mediumblob1) sha(mediumblob2) sha(mediumblob3) sha(mediumblob4) length(mediumblob1) length(mediumblob2) length(mediumblob3) length(mediumblob4) sha(longblob1) sha(longblob2) sha(longblob3) sha(longblob4) length(longblob1) length(longblob2) length(longblob3) length(longblob4)
0 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 NULL NULL NULL NULL NULL NULL NULL
1 b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f 240 240 240 240 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 24576 24576 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 24576 24576 24576 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 24576 24576 24576 24576
Run backup
rename table test.t2 to test.t2_orig;
create table test.t2 (
a int unsigned primary key,
tinyblob1 tinytext, # tinyblob -> tinytext
tinyblob2 text, # tinyblob -> text
tinyblob3 mediumtext, # tinyblob -> mediumtext
tinyblob4 longtext, # tinyblob -> longtext
blob1 tinytext, # blob -> tinytext
blob2 text, # blob -> text
blob3 mediumtext, # blob -> mediumtext
blob4 longtext, # blob -> longtext
mediumblob1 tinytext, # mediumblob -> tinytext
mediumblob2 text, # mediumblob -> text
mediumblob3 mediumtext,# mediumblob -> mediumtext
mediumblob4 longtext, # mediumblob -> longtext
longblob1 tinytext, # longblob -> tinytext
longblob2 text, # longblob -> text
longblob3 mediumtext, # longblob -> mediumtext
longblob4 longtext # longblob -> longtext
) engine=ndb;
select count(*) from test.t2;
count(*)
2
select a,
sha(tinyblob1), sha(tinyblob2), sha(tinyblob3), sha(tinyblob4),
length(tinyblob1), length(tinyblob2), length(tinyblob3), length(tinyblob4),
sha(blob1), sha(blob2), sha(blob3), sha(blob4),
length(blob1), length(blob2), length(blob3), length(blob4),
sha(mediumblob1), sha(mediumblob2), sha(mediumblob3), sha(mediumblob4),
length(mediumblob1), length(mediumblob2), length(mediumblob3), length(mediumblob4),
sha(longblob1), sha(longblob2), sha(longblob3), sha(longblob4),
length(longblob1), length(longblob2), length(longblob3), length(longblob4) from test.t2 order by a;
a sha(tinyblob1) sha(tinyblob2) sha(tinyblob3) sha(tinyblob4) length(tinyblob1) length(tinyblob2) length(tinyblob3) length(tinyblob4) sha(blob1) sha(blob2) sha(blob3) sha(blob4) length(blob1) length(blob2) length(blob3) length(blob4) sha(mediumblob1) sha(mediumblob2) sha(mediumblob3) sha(mediumblob4) length(mediumblob1) length(mediumblob2) length(mediumblob3) length(mediumblob4) sha(longblob1) sha(longblob2) sha(longblob3) sha(longblob4) length(longblob1) length(longblob2) length(longblob3) length(longblob4)
0 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 NULL NULL NULL NULL NULL NULL NULL
1 b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f b45dcdc72f779995c05640ed7baa8ee5602c560f 240 240 240 240 6824e9d1a458a3ceb7fa93ad783746f7698f1ba8 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 255 24576 24576 24576 6824e9d1a458a3ceb7fa93ad783746f7698f1ba8 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 255 24576 24576 24576 6824e9d1a458a3ceb7fa93ad783746f7698f1ba8 a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e a76f74b45fc6f668715f91d7bf13658bcbe3410e 255 24576 24576 24576
Warnings:
Warning 1265 Truncated value from TEXT field 'blob1'
Warning 1265 Truncated value from TEXT field 'mediumblob1'
Warning 1265 Truncated value from TEXT field 'longblob1'
drop table test.t2;
drop table test.t2_orig;
*****************************************************************************
Charset-aware truncation in blob -> tinytext and text ->tinyblob conversions
*****************************************************************************
# ndb_restore TEXT -> TINYBLOB and BLOB->TINYTEXT truncation with UTF8MB4
set character_set_client=UTF8MB4;
create table t2(id int primary key, text_val text character set UTF8MB4, blob_val blob)engine=ndb;
insert into t2 values(11111, REPEAT(UNHEX("E38182"), 100), REPEAT(UNHEX("E38182"), 100));
insert into t2 values(22222, CONCAT("AA",REPEAT(UNHEX("E38182"), 100)), CONCAT("AA",REPEAT(UNHEX("E38182"), 100)));
select length(text_val), char_length(text_val), length(blob_val), char_length(blob_val) from t2 order by id;
length(text_val) char_length(text_val) length(blob_val) char_length(blob_val)
300 100 300 300
302 102 302 302
# run backup
drop table t2;
create table t2(id int primary key, text_val tinyblob, blob_val tinytext character set UTF8MB4)engine=ndb;
# run restore
# run ndb_select_all to see charset-aware truncation in ndb
# text_val = TINYBLOB, truncation on byte boundary, mid-character
# last char E38182 truncated to E3
# blob_val = TINYTEXT, truncation on well-formed char boundary
# last char E38182 not truncated
id text_val blob_val
11111 256:E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E3 255:あああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
22222 256:4141E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E38182E381 254:AAああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
2 rows returned
NDBT_ProgramExit: 0 - OK
# run mysql select to see charset-aware truncation in mysqld
# blob_val = TINYTEXT, truncation on well-formed char boundary
# length = well-formed char length * sizeof(UTF8MB4 char)
# 1. pk-based read
select length(blob_val), char_length(blob_val) from t2 where id = 11111;
length(blob_val) char_length(blob_val)
255 85
select length(blob_val), char_length(blob_val) from t2 where id = 22222;
length(blob_val) char_length(blob_val)
254 86
# 2. scan
select length(blob_val), char_length(blob_val) from t2 order by id;
length(blob_val) char_length(blob_val)
255 85
254 86
# text_val = TINYBLOB, truncation on byte boundary, mid-character
# length = well-formed char length
# 1. pk-based read
select length(text_val), char_length(text_val) from t2 where id = 11111;
length(text_val) char_length(text_val)
255 255
Warnings:
Warning 1265 Truncated value from TEXT field 'text_val'
select length(text_val), char_length(text_val) from t2 where id = 22222;
length(text_val) char_length(text_val)
255 255
Warnings:
Warning 1265 Truncated value from TEXT field 'text_val'
# 2. scan
select length(text_val), char_length(text_val) from t2 order by id;
length(text_val) char_length(text_val)
255 255
255 255
Warnings:
Warning 1265 Truncated value from TEXT field 'text_val'
Warning 1265 Truncated value from TEXT field 'text_val'
drop table t2;