~drizzle-trunk/drizzle/development

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
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
#################################################
# Author: Jeb
# Date:   2006-09-07
# Purpose: To test having extra columns on the slave.
##################################################

# Some tests in here requre partitioning
-- source include/have_partition.inc

########### Clean up ################
--disable_warnings
--disable_query_log
DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t14a,t15,t16,t17;
--enable_query_log
--enable_warnings

#################################################
############ Different Table Def Test ###########
#################################################
# Purpose: To have different table def on the   #
#          master and slave. Most of these tests#
#          should stop the slave.               #
#################################################

--echo **** Diff Table Def Start ****

##############################################
### Try to replicate w/ PK on diff columns ###
### Should Stop Slave                      ###
##############################################

--echo *** On Slave ***
sync_slave_with_master;
STOP SLAVE;
RESET SLAVE;

eval CREATE TABLE t1 (a INT, b INT PRIMARY KEY, c CHAR(20),
                      d FLOAT DEFAULT '2.00', 
                      e CHAR(4) DEFAULT 'TEST') 
                      ENGINE=$engine_type;

--echo *** Create t1 on Master ***
connection master;
eval CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c CHAR(10)
                       ) ENGINE=$engine_type;

RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;

INSERT INTO t1 () VALUES(1,2,'TEXAS'),(2,1,'AUSTIN'),(3,4,'QA');
SELECT * FROM t1 ORDER BY a;

--echo *** Select from slave ***
sync_slave_with_master;
SELECT * FROM t1 ORDER BY a;

--echo *** Drop t1  ***
connection master;
DROP TABLE t1;
sync_slave_with_master;

############################################
### Try to replicate CHAR(10) to CHAR(5) ###
### Should Stop Slave or truncate value  ###
############################################

## BUG22086
--echo *** Create t2 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5),
                      d FLOAT DEFAULT '2.00',
                      e CHAR(5) DEFAULT 'TEST2')
                      ENGINE=$engine_type;

--echo *** Create t2 on Master ***
connection master;
eval CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Master Data Insert ***
connection master;

INSERT INTO t2 () VALUES(1,2,'Kyle, TEX'),(2,1,'JOE AUSTIN'),(3,4,'QA TESTING');
SELECT * FROM t2 ORDER BY a;

--echo *** Start Slave ***
connection slave;
START SLAVE;
wait_for_slave_to_stop;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
STOP SLAVE;
RESET SLAVE;
SELECT * FROM t2 ORDER BY a;

connection master;
RESET MASTER;

connection slave;
START SLAVE;

--echo *** Drop t2  ***
connection master;
DROP TABLE t2;
sync_slave_with_master;

####################################
### Try to replicate BLOB to INT ###
### Should Stop Slave            ###
####################################
--echo *** Create t3 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t3 (a INT, b INT PRIMARY KEY, c CHAR(20),
                      d FLOAT DEFAULT '2.00',
                      e CHAR(5) DEFAULT 'TEST2')
                      ENGINE=$engine_type;

--echo *** Create t3 on Master ***
connection master;
eval CREATE TABLE t3 (a BLOB, b INT PRIMARY KEY, c CHAR(20)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;

set @b1 = 'b1';
set @b1 = concat(@b1,@b1);

INSERT INTO t3 () VALUES(@b1,2,'Kyle, TEX'),(@b1,1,'JOE AUSTIN'),(@b1,4,'QA TESTING');

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

--echo *** Drop t3  ***
connection master;
DROP TABLE t3;
sync_slave_with_master;

#####################################################
# Columns with different types, more columns at end #
# Expect: proper error message (wrong types)        #
##################################################### 

--echo *** Create t4 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t4 (a INT, b INT PRIMARY KEY, c CHAR(20),
                      d FLOAT DEFAULT '2.00',
                      e CHAR(5) DEFAULT 'TEST2')
                      ENGINE=$engine_type;

--echo *** Create t4 on Master ***
connection master;
eval CREATE TABLE t4 (a DECIMAL(8,2), b INT PRIMARY KEY, c CHAR(20)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;

INSERT INTO t4 () VALUES(100.22,2,'Kyle, TEX'),(200.26,1,'JOE AUSTIN'),
                        (30000.22,4,'QA TESTING');

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

--echo *** Drop t4  ***
connection master;
DROP TABLE t4;
sync_slave_with_master;

#######################################################
# Columns with different types, same number of colums #
# Expect: Proper error message                        #
#######################################################

--echo *** Create t5 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t5 (a INT PRIMARY KEY, b CHAR(5),
                      c FLOAT, d INT, e DOUBLE,
                      f DECIMAL(8,2))ENGINE=$engine_type;

--echo *** Create t5 on Master ***
connection master;
eval CREATE TABLE t5 (a INT PRIMARY KEY, b VARCHAR(6),
                      c DECIMAL(8,2), d BIT, e BLOB,
                      f FLOAT) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;

INSERT INTO t5 () VALUES(1,'Kyle',200.23,1,'b1b1',23.00098),
                        (2,'JOE',300.01,0,'b2b2',1.0000009);

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

--echo *** Drop t5  ***
connection master;
DROP TABLE t5;
sync_slave_with_master;

#######################################################
################## Continued ##########################
#######################################################
# Columns with different types, same number of colums #
# Expect: Proper error message                        #
#######################################################

--echo *** Create t6 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t6 (a INT PRIMARY KEY, b CHAR(5),
                      c FLOAT, d INT)ENGINE=$engine_type;

--echo *** Create t6 on Master ***
connection master;
eval CREATE TABLE t6 (a INT PRIMARY KEY, b VARCHAR(6),
                      c DECIMAL(8,2), d BIT 
                      ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;

INSERT INTO t6 () VALUES(1,'Kyle',200.23,1),
                        (2,'JOE',300.01,0);

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3;
#START SLAVE;

--echo *** Drop t6  ***
connection master;
DROP TABLE t6;
connection slave;
DROP TABLE t6;
START SLAVE;
#sync_slave_with_master;


--echo **** Diff Table Def End ****

#######################################
#### Extra Column on Slave Testing ####
#######################################
# Purpose: To test extra colums on the#
#          Slave                      #
#######################################

--echo **** Extra Colums Start ****

##########################################
# More columns in slave at end of table, # 
# added columns have default values      #
# Expect: it should work, default values #
#         should be used                 #
##########################################

--echo *** Create t7 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t7 (a INT KEY, b BLOB, c CHAR(5),
                      d TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
                      e CHAR(20) DEFAULT 'Extra Column Testing')
                      ENGINE=$engine_type;

--echo *** Create t7 on Master ***
connection master;
eval CREATE TABLE t7 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t7 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
SELECT * FROM t7 ORDER BY a;

--echo *** Select from slave ***
sync_slave_with_master;
SELECT * FROM t7 ORDER BY a;

--echo *** Drop t7  ***
connection master;
DROP TABLE t7;
sync_slave_with_master;

###########################################
# More columns in slave at end of table,  #
# added columns do not have default values#
# Expect: Proper error message            #
###########################################
# NOTE: This should fail but currently    #
#       works. BUG#22101                  #
###########################################
--echo *** Create t8 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t8 (a INT KEY, b BLOB, c CHAR(5),
                      d TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
                      e INT)ENGINE=$engine_type;

--echo *** Create t8 on Master ***
connection master;
eval CREATE TABLE t8 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t8 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');

### Uncomment once bug is fixed

#connection slave;
#wait_for_slave_to_stop;
#--replace_result $MASTER_MYPORT MASTER_PORT
#--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
#--query_vertical SHOW SLAVE STATUS
#SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
#START SLAVE;

--echo *** Drop t8  ***
connection master;
DROP TABLE t8;
sync_slave_with_master;

###########################################
############# Continued ###################
# More columns in slave at end of table,  #
# added columns do not have default values#
# Expect: Proper error message            #
###########################################
# Bug#22234, Bug#23907 Extra Slave Col is not 
# erroring on extra col with no default values.
########################################################
#--echo *** Create t9 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t9 (a INT KEY, b BLOB, c CHAR(5),
                      d TIMESTAMP,
                      e INT NOT NULL) ENGINE=$engine_type;

--echo *** Create t9 on Master ***
connection master;
eval CREATE TABLE t9 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');

--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

#--echo *** Drop t9  ***
#connection master;
#DROP TABLE t9;
#sync_slave_with_master;

############################################
# More columns in slave at middle of table #
# Expect: Proper error message             #
############################################
--echo  *** Create t10 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t10 (a INT KEY, b BLOB, f DOUBLE DEFAULT '233', 
                      c CHAR(5), e INT DEFAULT '1')ENGINE=$engine_type;

--echo *** Create t10 on Master ***
connection master;
eval CREATE TABLE t10 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t10 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

--echo *** Drop t10  ***
connection master;
DROP TABLE t10;
sync_slave_with_master;

############################################
############## Continued ###################
############################################
# More columns in slave at middle of table #
# Expect: Proper error message             #
############################################
--echo  *** Create t11 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t11 (a INT KEY, b BLOB, f TEXT,
                      c CHAR(5) DEFAULT 'test', e INT DEFAULT '1')ENGINE=$engine_type;

--echo *** Create t11 on Master ***
connection master;
eval CREATE TABLE t11 (a INT PRIMARY KEY, b BLOB, c VARCHAR(254)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t11 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

--echo *** Drop t11  ***
connection master;
DROP TABLE t11;
sync_slave_with_master;

############################################
############## Continued ###################
############################################
# More columns in slave at middle of table #
# Expect: This one should pass blob-text   #
############################################
--echo  *** Create t12 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t12 (a INT KEY, b BLOB, f TEXT,
                      c CHAR(5) DEFAULT 'test', e INT DEFAULT '1')ENGINE=$engine_type;

--echo *** Create t12 on Master ***
connection master;
eval CREATE TABLE t12 (a INT PRIMARY KEY, b BLOB, c BLOB
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t12 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
SELECT * FROM t12 ORDER BY a;

--echo *** Select on Slave ***
sync_slave_with_master;
SELECT * FROM t12 ORDER BY a;

--echo *** Drop t12  ***
connection master;
DROP TABLE t12;
sync_slave_with_master;

--echo **** Extra Colums End ****

###############################
# BUG#22177 CURRENT_TIMESTAMP #
# Sould work with ^           #
###############################
--echo *** BUG 22177 Start ***
--echo *** Create t13 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t13 (a INT KEY, b BLOB, c CHAR(5),
                      d INT DEFAULT '1',
                      e TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
                      )ENGINE=$engine_type;

--echo *** Create t13 on Master ***
connection master;
eval CREATE TABLE t13 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t13 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
SELECT * FROM t13 ORDER BY a;

--echo *** Select on Slave ****
sync_slave_with_master;
--replace_column 5 CURRENT_TIMESTAMP 
SELECT * FROM t13 ORDER BY a;

--echo *** Drop t13  ***
connection master;
DROP TABLE t13;
sync_slave_with_master;

--echo *** 22117 END *** 

##############################
# ALTER MASTER TABLE TESTING #
##############################

--echo *** Alter Master Table Testing Start ***

####################################################
# - Alter Master adding columns at middle of table #
#   Expect: columns added                          #
####################################################

--echo *** Create t14 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t14 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
                      c6 INT DEFAULT '1',
                      c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
                      )ENGINE=$engine_type;

--echo *** Create t14 on Master ***
connection master;
eval CREATE TABLE t14 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
ALTER TABLE t14 ADD COLUMN c2 DECIMAL(8,2) AFTER c1;
ALTER TABLE t14 ADD COLUMN c3 TEXT AFTER c2;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t14 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle'),
                        (2,2.00,'This Test Should work',@b1,'JOE'),
                        (3,3.00,'If is does not, I will open a bug',@b1,'QA');
SELECT * FROM t14 ORDER BY c1;


--echo *** Select on Slave ****
sync_slave_with_master;
--replace_column 7 CURRENT_TIMESTAMP
SELECT * FROM t14 ORDER BY c1;

####################################################
# - Alter Master drop column at end of table      #
#   Expect: column dropped                        #
####################################################

--echo *** Create t14a on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t14a (c1 INT KEY, c4 BLOB, c5 CHAR(5),
                      c6 INT DEFAULT '1',
                      c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
                      )ENGINE=$engine_type;

--echo *** Create t14a on Master ***
connection master;
eval CREATE TABLE t14a (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t14a () VALUES(1,@b1,'Kyle'),
                        (2,@b1,'JOE'),
                        (3,@b1,'QA');

SELECT * FROM t14a ORDER BY c1;
--echo *** Select on Slave ****
sync_slave_with_master;
--replace_column 5 CURRENT_TIMESTAMP
SELECT * FROM t14a ORDER BY c1;
STOP SLAVE;
RESET SLAVE;

--echo *** Master Drop c5 ***
connection master;
ALTER TABLE t14a DROP COLUMN c5;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);

INSERT INTO t14a () VALUES(4,@b1),
                        (5,@b1),
                        (6,@b1);
SELECT * FROM t14a ORDER BY c1;

--echo *** Select on Slave ****
sync_slave_with_master;
--replace_column 5 CURRENT_TIMESTAMP
SELECT * FROM t14a ORDER BY c1;

####################################################
# - Alter Master Dropping columns from the middle. #
#   Expect: columns dropped                        #
####################################################

--echo *** connect to master and drop columns ***
connection master;
ALTER TABLE t14 DROP COLUMN c2;
ALTER TABLE t14 DROP COLUMN c4;
--echo *** Select from Master ***
SELECT * FROM t14 ORDER BY c1;

--echo *** Select from Slave ***
sync_slave_with_master;
--replace_column 5 CURRENT_TIMESTAMP
SELECT * FROM t14 ORDER BY c1;

--echo *** Drop t14  ***
connection master;
DROP TABLE t14;
sync_slave_with_master;

##############################################################
# - Alter Master adding columns that already exist on slave. #
#  Expect: proper error message                              #
##############################################################

--echo *** Create t15 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t15 (c1 INT KEY, c2 DECIMAL(8,2), c3 TEXT,
                      c4 BLOB, c5 CHAR(5),
                      c6 INT DEFAULT '1',
                      c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
                      )ENGINE=$engine_type;

--echo *** Create t15 on Master ***
connection master;
eval CREATE TABLE t15 (c1 INT PRIMARY KEY, c2 DECIMAL(8,2), c3 TEXT,
                      c4 BLOB, c5 CHAR(5)) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t15 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle'),
                        (2,2.00,'This Test Should work',@b1,'JOE'),
                        (3,3.00,'If is does not, I will open a bug',@b1,'QA');
SELECT * FROM t15 ORDER BY c1;


--echo *** Select on Slave ****
sync_slave_with_master;
--replace_column 7 CURRENT_TIMESTAMP
SELECT * FROM t15 ORDER BY c1;

--echo *** Add column on master that is a Extra on Slave ***
connection master;
ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5;

--echo ********************************************
--echo *** Expect slave to fail with Error 1060 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;

--echo *** Try to insert in master ****
connection master;
INSERT INTO t15 () VALUES(5,2.00,'Replication Testing',@b1,'Buda',2);
SELECT * FROM t15 ORDER BY c1;

#SHOW BINLOG EVENTS;

--echo *** Try to select from slave ****
sync_slave_with_master;
--replace_column 7 CURRENT_TIMESTAMP
SELECT * FROM t15 ORDER BY c1;

--echo *** DROP TABLE t15 ***
connection master;
DROP TABLE t15;
sync_slave_with_master;

####################################
# - Alter Master and ADD PARTITION #
#   Expect:?                       #
####################################

--echo *** Create t16 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t16 (c1 INT KEY, c2 DECIMAL(8,2), c3 TEXT,
                      c4 BLOB, c5 CHAR(5),
                      c6 INT DEFAULT '1',
                      c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
                      )ENGINE=$engine_type;

--echo *** Create t16 on Master ***
connection master;
eval CREATE TABLE t16 (c1 INT PRIMARY KEY, c2 DECIMAL(8,2), c3 TEXT,
                      c4 BLOB, c5 CHAR(5))ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t16 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle'),
                        (2,2.00,'This Test Should work',@b1,'JOE'),
                        (3,3.00,'If is does not, I will open a bug',@b1,'QA');
SELECT * FROM t16 ORDER BY c1;

--echo *** Select on Slave ****
sync_slave_with_master;
--replace_column 7 CURRENT_TIMESTAMP
SELECT * FROM t16 ORDER BY c1;

--echo *** Add Partition on master ***
connection master;
ALTER TABLE t16 PARTITION BY KEY(c1) PARTITIONS 4;
INSERT INTO t16 () VALUES(4,1.00,'Replication Rocks',@b1,'Omer');
SHOW CREATE TABLE t16;

--echo *** Show table on Slave ****
sync_slave_with_master;
SHOW CREATE TABLE t16;

--echo *** DROP TABLE t16 ***
connection master;
DROP TABLE t16;
sync_slave_with_master;

--echo *** Alter Master End ***

############################################
### Try to replicate BIGINT to SMALLINT ###
### Should Stop Slave                   ###
############################################

--echo *** Create t17 on slave  ***
STOP SLAVE;
RESET SLAVE;
eval CREATE TABLE t17 (a SMALLINT, b INT PRIMARY KEY, c CHAR(5),
                      d FLOAT DEFAULT '2.00',
                      e CHAR(5) DEFAULT 'TEST2')
                      ENGINE=$engine_type;

--echo *** Create t17 on Master ***
connection master;
eval CREATE TABLE t17 (a BIGINT PRIMARY KEY, b INT, c CHAR(10)
                       ) ENGINE=$engine_type;
RESET MASTER;

--echo *** Start Slave ***
connection slave;
START SLAVE;

--echo *** Master Data Insert ***
connection master;

INSERT INTO t17 () VALUES(9223372036854775807,2,'Kyle, TEX');

--echo ********************************************
--echo *** Expect slave to fail with Error 1522 ***
--echo ********************************************
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;

--echo ** DROP table t17 ***
connection master;
DROP TABLE t17;
sync_slave_with_master;

#### Clean Up ####
--disable_warnings
--disable_query_log
connection master;
DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t14a,t15,t16,t17;
sync_slave_with_master;
connection master;
--enable_query_log
--enable_warnings

# END 5.1 Test Case