1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
|
#!/usr/bin/perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use TableChecksum;
use TableParser;
use Quoter;
use DSNParser;
use Sandbox;
use PerconaTest;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => "Cannot connect to sandbox master";
}
else {
plan tests => 52;
}
$sb->create_dbs($dbh, ['test']);
my $q = new Quoter();
my $tp = new TableParser(Quoter => $q);
my $c = new TableChecksum(Quoter=>$q);
my $t;
my %args = map { $_ => undef }
qw(db tbl tbl_struct algorithm function crc_wid crc_type opt_slice);
throws_ok (
sub { $c->best_algorithm( %args, algorithm => 'foo', ) },
qr/Invalid checksum algorithm/,
'Algorithm=foo',
);
is (
$c->best_algorithm(
algorithm => 'CHECKSUM',
dbh => '4.1.1',
),
'CHECKSUM',
'Prefers CHECKSUM',
);
is (
$c->best_algorithm(
dbh => '4.1.1',
),
'CHECKSUM',
'Default is CHECKSUM',
);
is (
$c->best_algorithm(
algorithm => 'CHECKSUM',
dbh => '4.1.1',
where => 1,
),
'BIT_XOR',
'CHECKSUM eliminated by where',
);
is (
$c->best_algorithm(
algorithm => 'CHECKSUM',
dbh => '4.1.1',
chunk => 1,
),
'BIT_XOR',
'CHECKSUM eliminated by chunk',
);
is (
$c->best_algorithm(
algorithm => 'CHECKSUM',
dbh => '4.1.1',
replicate => 1,
),
'BIT_XOR',
'CHECKSUM eliminated by replicate',
);
is (
$c->best_algorithm(
dbh => '4.1.1',
count => 1,
),
'BIT_XOR',
'Default CHECKSUM eliminated by count',
);
is (
$c->best_algorithm(
algorithm => 'CHECKSUM',
dbh => '4.1.1',
count => 1,
),
'CHECKSUM',
'Explicit CHECKSUM not eliminated by count',
);
is (
$c->best_algorithm(
algorithm => 'CHECKSUM',
dbh => '4.0.0',
),
'CHECKSUM',
'Ignore version, always use CHECKSUM',
);
is (
$c->best_algorithm(
algorithm => 'BIT_XOR',
dbh => '4.1.1',
),
'BIT_XOR',
'BIT_XOR as requested',
);
is (
$c->best_algorithm(
algorithm => 'BIT_XOR',
dbh => '4.0.0',
),
'BIT_XOR',
'Ignore version, always use BIT_XOR',
);
is (
$c->best_algorithm(
algorithm => 'ACCUM',
dbh => '4.1.1',
),
'ACCUM',
'ACCUM as requested',
);
ok($c->is_hash_algorithm('ACCUM'), 'ACCUM is hash');
ok($c->is_hash_algorithm('BIT_XOR'), 'BIT_XOR is hash');
ok(!$c->is_hash_algorithm('CHECKSUM'), 'CHECKSUM is not hash');
is (
$c->make_xor_slices(
query => 'FOO',
crc_wid => 1,
),
"LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(FOO, 1, 1), 16, 10) "
. "AS UNSIGNED)), 10, 16), 1, '0')",
'FOO XOR slices 1 wide',
);
is (
$c->make_xor_slices(
query => 'FOO',
crc_wid => 16,
),
"LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(FOO, 1, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0')",
'FOO XOR slices 16 wide',
);
is (
$c->make_xor_slices(
query => 'FOO',
crc_wid => 17,
),
"LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(FOO, 1, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0'), "
. "LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(FOO, 17, 1), 16, 10) "
. "AS UNSIGNED)), 10, 16), 1, '0')",
'FOO XOR slices 17 wide',
);
is (
$c->make_xor_slices(
query => 'FOO',
crc_wid => 32,
),
"LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(FOO, 1, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0'), "
. "LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(FOO, 17, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0')",
'FOO XOR slices 32 wide',
);
is (
$c->make_xor_slices(
query => 'FOO',
crc_wid => 32,
opt_slice => 0,
),
"LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(\@crc := FOO, 1, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0'), "
. "LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(\@crc, 17, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0')",
'XOR slice optimized in slice 0',
);
is (
$c->make_xor_slices(
query => 'FOO',
crc_wid => 32,
opt_slice => 1,
),
"LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(\@crc, 1, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0'), "
. "LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(\@crc := FOO, 17, 16), 16, 10) "
. "AS UNSIGNED)), 10, 16), 16, '0')",
'XOR slice optimized in slice 1',
);
$t = $tp->parse(load_file('t/lib/samples/sakila.film.sql'));
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
),
q{`film_id`, `title`, `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, `last_update` + 0 AS `last_update`, }
. q{SHA1(CONCAT_WS('#', }
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0, }
. q{CONCAT(ISNULL(`description`), ISNULL(`release_year`), }
. q{ISNULL(`original_language_id`), ISNULL(`length`), }
. q{ISNULL(`rating`), ISNULL(`special_features`))))},
'SHA1 query for sakila.film',
);
is (
$c->make_row_checksum(
function => 'FNV_64',
tbl_struct => $t,
),
q{`film_id`, `title`, `description`, `release_year`, `language_id`, `original_language_id`, `rental_duration`, `rental_rate`, `length`, `replacement_cost`, `rating`, `special_features`, `last_update` + 0 AS `last_update`, }
. q{FNV_64(}
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0)},
'FNV_64 query for sakila.film',
);
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
cols => [qw(film_id)],
),
q{`film_id`, SHA1(`film_id`)},
'SHA1 query for sakila.film with only one column',
);
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
cols => [qw(FILM_ID)],
),
q{`film_id`, SHA1(`film_id`)},
'Column names are case-insensitive',
);
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
cols => [qw(film_id title)],
sep => '%',
),
q{`film_id`, `title`, SHA1(CONCAT_WS('%', `film_id`, `title`))},
'Separator',
);
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
cols => [qw(film_id title)],
sep => "'%'",
),
q{`film_id`, `title`, SHA1(CONCAT_WS('%', `film_id`, `title`))},
'Bad separator',
);
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
cols => [qw(film_id title)],
sep => "'''",
),
q{`film_id`, `title`, SHA1(CONCAT_WS('#', `film_id`, `title`))},
'Really bad separator',
);
$t = $tp->parse(load_file('t/lib/samples/sakila.rental.float.sql'));
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
),
q{`rental_id`, `foo`, SHA1(CONCAT_WS('#', `rental_id`, `foo`))},
'FLOAT column is like any other',
);
is (
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
float_precision => 5,
),
q{`rental_id`, ROUND(`foo`, 5), SHA1(CONCAT_WS('#', `rental_id`, ROUND(`foo`, 5)))},
'FLOAT column is rounded to 5 places',
);
$t = $tp->parse(load_file('t/lib/samples/sakila.film.sql'));
like(
$c->make_row_checksum(
function => 'SHA1',
tbl_struct => $t,
trim => 1,
),
qr{TRIM\(`title`\)},
'VARCHAR column is trimmed',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'CHECKSUM',
function => 'SHA1',
crc_wid => 40,
crc_type => 'varchar',
),
'CHECKSUM TABLE `sakila`.`film`',
'Sakila.film CHECKSUM',
);
throws_ok (
sub { $c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'BIT_XOR',
crc_wid => 40,
cols => [qw(film_id)],
crc_type => 'varchar',
function => 'SHA1',
algorithm => 'CHECKSUM TABLE',
)
},
qr/missing checksum algorithm/,
'Complains about bad algorithm',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'BIT_XOR',
function => 'SHA1',
crc_wid => 40,
cols => [qw(film_id)],
crc_type => 'varchar',
),
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(LOWER(CONCAT(LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(SHA1(`film_id`), 1, }
. q{16), 16, 10) AS UNSIGNED)), 10, 16), 16, '0'), }
. q{LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(SHA1(`film_id`), 17, 16), 16, }
. q{10) AS UNSIGNED)), 10, 16), 16, '0'), }
. q{LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(SHA1(`film_id`), 33, 8), 16, }
. q{10) AS UNSIGNED)), 10, 16), 8, '0'))), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film SHA1 BIT_XOR',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'BIT_XOR',
function => 'FNV_64',
crc_wid => 99,
cols => [qw(film_id)],
crc_type => 'bigint',
),
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(LOWER(CONV(BIT_XOR(CAST(FNV_64(`film_id`) AS UNSIGNED)), 10, 16)), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film FNV_64 BIT_XOR',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'BIT_XOR',
function => 'FNV_64',
crc_wid => 99,
cols => [qw(film_id)],
buffer => 1,
crc_type => 'bigint',
),
q{SELECT SQL_BUFFER_RESULT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(LOWER(CONV(BIT_XOR(CAST(FNV_64(`film_id`) AS UNSIGNED)), 10, 16)), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film FNV_64 BIT_XOR',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'BIT_XOR',
function => 'CRC32',
crc_wid => 99,
cols => [qw(film_id)],
buffer => 1,
crc_type => 'int',
),
q{SELECT SQL_BUFFER_RESULT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(`film_id`) AS UNSIGNED)), 10, 16)), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film CRC32 BIT_XOR',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'BIT_XOR',
function => 'SHA1',
crc_wid => 40,
cols => [qw(film_id)],
replicate => 'test.checksum',
crc_type => 'varchar',
),
q{REPLACE /*PROGRESS_COMMENT*/ INTO test.checksum }
. q{(db, tbl, chunk, boundaries, this_cnt, this_crc) }
. q{SELECT ?, ?, /*CHUNK_NUM*/ ?, COUNT(*) AS cnt, }
. q{COALESCE(LOWER(CONCAT(LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(SHA1(`film_id`), 1, }
. q{16), 16, 10) AS UNSIGNED)), 10, 16), 16, '0'), }
. q{LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(SHA1(`film_id`), 17, 16), 16, }
. q{10) AS UNSIGNED)), 10, 16), 16, '0'), }
. q{LPAD(CONV(BIT_XOR(CAST(CONV(SUBSTRING(SHA1(`film_id`), 33, 8), 16, }
. q{10) AS UNSIGNED)), 10, 16), 8, '0'))), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film SHA1 BIT_XOR with replication',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'ACCUM',
function => 'SHA1',
crc_wid => 40,
crc_type => 'varchar',
),
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
. q{SHA1(CONCAT(@crc, SHA1(CONCAT_WS('#', }
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0, }
. q{CONCAT(ISNULL(`description`), ISNULL(`release_year`), }
. q{ISNULL(`original_language_id`), ISNULL(`length`), }
. q{ISNULL(`rating`), ISNULL(`special_features`)))))))), 40), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film SHA1 ACCUM',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'ACCUM',
function => 'FNV_64',
crc_wid => 16,
crc_type => 'bigint',
),
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
. q{CONV(CAST(FNV_64(CONCAT(@crc, FNV_64(}
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0}
. q{))) AS UNSIGNED), 10, 16))), 16), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film FNV_64 ACCUM',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'ACCUM',
function => 'CRC32',
crc_wid => 16,
crc_type => 'int',
cols => [qw(film_id)],
),
q{SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, }
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
. q{CONV(CAST(CRC32(CONCAT(@crc, CRC32(`film_id`}
. q{))) AS UNSIGNED), 10, 16))), 16), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film CRC32 ACCUM',
);
is (
$c->make_checksum_query(
%args,
db => 'sakila',
tbl => 'film',
tbl_struct => $t,
algorithm => 'ACCUM',
function => 'SHA1',
crc_wid => 40,
replicate => 'test.checksum',
crc_type => 'varchar',
),
q{REPLACE /*PROGRESS_COMMENT*/ INTO test.checksum }
. q{(db, tbl, chunk, boundaries, this_cnt, this_crc) }
. q{SELECT ?, ?, /*CHUNK_NUM*/ ?, COUNT(*) AS cnt, }
. q{COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, '0'), }
. q{SHA1(CONCAT(@crc, SHA1(CONCAT_WS('#', }
. q{`film_id`, `title`, `description`, `release_year`, `language_id`, }
. q{`original_language_id`, `rental_duration`, `rental_rate`, `length`, }
. q{`replacement_cost`, `rating`, `special_features`, `last_update` + 0, }
. q{CONCAT(ISNULL(`description`), ISNULL(`release_year`), }
. q{ISNULL(`original_language_id`), ISNULL(`length`), }
. q{ISNULL(`rating`), ISNULL(`special_features`)))))))), 40), 0) AS crc }
. q{FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/},
'Sakila.film SHA1 ACCUM with replication',
);
is ( $c->crc32('hello world'), 222957957, 'CRC32 of hello world');
# #############################################################################
# Sandbox tests.
# #############################################################################
like(
$c->choose_hash_func(
dbh => $dbh,
),
qr/CRC32|FNV_64|MD5/,
'CRC32, FNV_64 or MD5 is default',
);
like(
$c->choose_hash_func(
dbh => $dbh,
function => 'SHA99',
),
qr/CRC32|FNV_64|MD5/,
'SHA99 does not exist so I get CRC32 or friends',
);
is(
$c->choose_hash_func(
dbh => $dbh,
function => 'MD5',
),
'MD5',
'MD5 requested and MD5 granted',
);
is(
$c->optimize_xor(
dbh => $dbh,
function => 'SHA1',
),
'2',
'SHA1 slice is 2',
);
is(
$c->optimize_xor(
dbh => $dbh,
function => 'MD5',
),
'1',
'MD5 slice is 1',
);
is_deeply(
[$c->get_crc_type($dbh, 'CRC32')],
[qw(int 10)],
'Type and length of CRC32'
);
my $want = $sandbox_version ge '8.0' ? [qw(varchar 128)] : [qw(varchar 96)];
is_deeply(
[$c->get_crc_type($dbh, 'MD5')],
$want,
'Type and length of MD5'
);
# #############################################################################
# Issue 94: Enhance mk-table-checksum, add a --ignorecols option
# #############################################################################
$sb->load_file('master', 't/lib/samples/issue_94.sql');
$t= $tp->parse( $tp->get_create_table($dbh, 'test', 'issue_94') );
my $query = $c->make_checksum_query(
db => 'test',
tbl => 'issue_47',
tbl_struct => $t,
algorithm => 'ACCUM',
function => 'CRC32',
crc_wid => 16,
crc_type => 'int',
opt_slice => undef,
cols => undef,
sep => '#',
replicate => undef,
precision => undef,
trim => undef,
ignorecols => {'c'=>1},
);
is($query,
'SELECT /*PROGRESS_COMMENT*//*CHUNK_NUM*/ COUNT(*) AS cnt, COALESCE(RIGHT(MAX(@crc := CONCAT(LPAD(@cnt := @cnt + 1, 16, \'0\'), CONV(CAST(CRC32(CONCAT(@crc, CRC32(CONCAT_WS(\'#\', `a`, `b`)))) AS UNSIGNED), 10, 16))), 16), 0) AS crc FROM /*DB_TBL*//*INDEX_HINT*//*WHERE*/',
'Ignores specified columns');
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;
|