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
|
#########################################################################
# A. TEST CASES FOR DDL ON STORED ROUTINES. #
#########################################################################
#
# Test case to verify if CREATE routine statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_create_routine_failure";
CREATE PROCEDURE p() SELECT 1;
ERROR HY000: Failed to CREATE PROCEDURE p
CREATE FUNCTION f() RETURNS INT return 1;
ERROR HY000: Failed to CREATE FUNCTION f
SET SESSION DEBUG="-d,simulate_create_routine_failure";
# Data-dictionary objects for p and f are not stored on
# an error/a transaction rollback.
# Following statements fails as p and f does not exists.
SHOW CREATE PROCEDURE p;
ERROR 42000: PROCEDURE p does not exist
SHOW CREATE FUNCTION f;
ERROR 42000: FUNCTION f does not exist
# Binlog event for failed create routine statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
# Routines are created and binlog event is written on a transaction
# commit.
CREATE PROCEDURE p() SELECT 1;
CREATE FUNCTION f() RETURNS INT return 1;
SHOW CREATE PROCEDURE p;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE FUNCTION f;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
#
# Test case to verify if ALTER routine statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_alter_routine_failure";
ALTER FUNCTION f comment "atomic DDL on routine";
ERROR HY000: Failed to ALTER FUNCTION test.f
ALTER PROCEDURE p comment "atomic DDL on routine";
ERROR HY000: Failed to ALTER PROCEDURE test.p
SET SESSION DEBUG="-d,simulate_alter_routine_failure";
SET SESSION DEBUG="+d,simulate_alter_routine_xcommit_failure";
ALTER FUNCTION f comment "atomic DDL on routine";
ERROR HY000: Failed to ALTER FUNCTION test.f
ALTER PROCEDURE p comment "atomic DDL on routine";
ERROR HY000: Failed to ALTER PROCEDURE test.p
SET SESSION DEBUG="-d,simulate_alter_routine_xcommit_failure";
# Comment for stored routines is not updated on an error/a transaction
# rollback.
SHOW CREATE PROCEDURE p;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE FUNCTION f;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
# Binlog event for failed ALTER routine statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
# Routines are altered and binlog event is written on a transaction commit.
ALTER FUNCTION f comment "atomic DDL on routine";
ALTER PROCEDURE p comment "atomic DDL on routine";
SHOW CREATE FUNCTION f;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
COMMENT 'atomic DDL on routine'
return 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE PROCEDURE p;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
COMMENT 'atomic DDL on routine'
SELECT 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; ALTER FUNCTION f comment "atomic DDL on routine"
binlog.000001 # Query # # use `test`; ALTER PROCEDURE p comment "atomic DDL on routine"
#
# Test case to verify if DROP routine statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_drop_routine_failure";
DROP FUNCTION f;
ERROR HY000: Failed to DROP FUNCTION test.f
DROP PROCEDURE p;
ERROR HY000: Failed to DROP PROCEDURE test.p
SET SESSION DEBUG="-d,simulate_drop_routine_failure";
# On an error/a transaction rollback, routines are not dropped. Following
# statements pass in this case.
SHOW CREATE PROCEDURE p;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
COMMENT 'atomic DDL on routine'
SELECT 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE FUNCTION f;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
COMMENT 'atomic DDL on routine'
return 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
# Binlog event for failed drop routine statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; ALTER FUNCTION f comment "atomic DDL on routine"
binlog.000001 # Query # # use `test`; ALTER PROCEDURE p comment "atomic DDL on routine"
# Routines are dropped and binlog event is written on transaction commit.
DROP FUNCTION f;
DROP PROCEDURE p;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; ALTER FUNCTION f comment "atomic DDL on routine"
binlog.000001 # Query # # use `test`; ALTER PROCEDURE p comment "atomic DDL on routine"
binlog.000001 # Query # # use `test`; DROP FUNCTION f
binlog.000001 # Query # # use `test`; DROP PROCEDURE p
SHOW CREATE PROCEDURE p;
ERROR 42000: PROCEDURE p does not exist
SHOW CREATE FUNCTION f;
ERROR 42000: FUNCTION f does not exist
#########################################################################
# B. TEST CASES FOR DDL ON TRIGGERS. #
#########################################################################
CREATE TABLE t1(a INT);
CREATE TRIGGER trig1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trig1 INSERT t1 BEGIN END BEFORE # # # # # #
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(a INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END
#
# Test case to verify if CREATE trigger statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_create_trigger_failure";
CREATE TRIGGER trig2 AFTER INSERT ON t1 FOR EACH ROW BEGIN END;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_create_trigger_failure";
# trig2 is not stored in the DD tables on an error/a transaction rollback.
# Following statement does not lists trig2 trigger.
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trig1 INSERT t1 BEGIN END BEFORE # # # # # #
# Binlog for failed create trigger statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(a INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END
# Trigger is created and binlog event is written on a transaction commit.
CREATE TRIGGER trig2 AFTER INSERT ON t1 FOR EACH ROW BEGIN END;
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trig1 INSERT t1 BEGIN END BEFORE # # # # # #
trig2 INSERT t1 BEGIN END AFTER # # # # # #
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(a INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig2 AFTER INSERT ON t1 FOR EACH ROW BEGIN END
#
# Test case to verify if DROP trigger statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_drop_trigger_failure";
DROP TRIGGER trig2;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_drop_trigger_failure";
# trig2 is not dropped from the DD tables on an error/a transaction
# rollback.
# Following statement lists trig2 trigger.
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trig1 INSERT t1 BEGIN END BEFORE # # # # # #
trig2 INSERT t1 BEGIN END AFTER # # # # # #
# Binlog for failed drop trigger statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(a INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig2 AFTER INSERT ON t1 FOR EACH ROW BEGIN END
# Trigger is dropped and binlog event is written on a transaction commit.
DROP TRIGGER trig2;
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trig1 INSERT t1 BEGIN END BEFORE # # # # # #
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(a INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN END
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER trig2 AFTER INSERT ON t1 FOR EACH ROW BEGIN END
binlog.000001 # Query # # use `test`; DROP TRIGGER trig2
DROP TABLE t1;
#########################################################################
# C. TEST CASES FOR DDL ON EVENTS. #
#########################################################################
#
# Test case to verify if CREATE EVENT statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_create_event_failure";
CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_create_event_failure";
# DD object of event is not stored on an error/a transaction rollback.
# Following statement does not list any events.
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
# Binlog event for failed create event statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
# DD object for event is stored and binlog is written in a transaction
# commit cases.
CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test event1 # # RECURRING NULL 1 YEAR # # ENABLED 1 # # #
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
# Binlog event for "create event if not exists" statement is
# created on a transaction commit.
CREATE EVENT IF NOT EXISTS event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1;
Warnings:
Note 1537 Event 'event1' already exists
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT IF NOT EXISTS event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
#
# Test case to verify if ALTER EVENT statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_alter_event_failure";
ALTER EVENT event1 COMMENT "Atomic Event's DDL";
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_alter_event_failure";
# DD object of event is not altered on an error/a transaction rollback.
# Hence changes are not reflected in the following statements.
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test event1 # # RECURRING NULL 1 YEAR # # ENABLED 1 # # #
# Binlog event for failed alter event statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT IF NOT EXISTS event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
# Event is altered and binlog event is written on a transaction commit.
ALTER EVENT event1 COMMENT "Atomic Event's DDL";
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test event1 # # RECURRING NULL 1 YEAR # # ENABLED 1 # # #
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT IF NOT EXISTS event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; ALTER EVENT event1 COMMENT "Atomic Event's DDL"
#
# Test case to verify if DROP EVENT statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_drop_event_failure";
DROP EVENT event1;
ERROR HY000: Unknown error
DROP EVENT IF EXISTS event1;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_drop_event_failure";
# On error/transaction rollback, event is not dropped. Following
# statements list events.
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test event1 # # RECURRING NULL 1 YEAR # # ENABLED 1 # # #
# Binlog event for failed drop event statement is not created.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT IF NOT EXISTS event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; ALTER EVENT event1 COMMENT "Atomic Event's DDL"
# Event is dropped and binlog event is written on a transaction commit.
DROP EVENT event1;
DROP EVENT IF EXISTS event1;
Warnings:
Note 1305 Event event1 does not exist
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT IF NOT EXISTS event1 ON SCHEDULE EVERY 1 YEAR DO SELECT 1
binlog.000001 # Query # # use `test`; ALTER EVENT event1 COMMENT "Atomic Event's DDL"
binlog.000001 # Query # # use `test`; DROP EVENT event1
binlog.000001 # Query # # use `test`; DROP EVENT IF EXISTS event1
#########################################################################
# D. TEST CASES FOR DDL ON VIEWS. #
#########################################################################
CREATE VIEW v1 AS SELECT 1;
CREATE VIEW v2 AS SELECT * FROM v1;
DROP VIEW v1;
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
#
# Test case to verify if CREATE VIEW statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_create_view_failure";
CREATE VIEW v1 AS SELECT 1;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_create_view_failure";
# DD object for view v1 is not stored and binlog event for view v1
# is not written in an error/a rollback scenarios.
# View v1 is not listed in the following statement.
SHOW TABLES;
Tables_in_test
v2
# Following statement fails as view v1 does not exists.
SHOW CREATE VIEW v1;
ERROR 42S02: Table 'test.v1' doesn't exist
# View v2 state remains as invalid after transaction rollback.
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
# Binlog for failed create view is not written.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
# On transaction commit, DD object of view is stored and binlog
# event for view v1 is written.
CREATE VIEW v1 AS SELECT 1;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci
# Referencing view v2's status is updated.
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
# View v1 is listed.
SHOW TABLES;
Tables_in_test
v1
v2
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
#
# Test case to verify if ALTER VIEW statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_create_view_failure";
ALTER VIEW v1 AS SELECT 1 as a1, 2 AS a2;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_create_view_failure";
# DD object for view v1 is not stored and binlog event for view v1
# is not written in an error/a rollback scenarios.
# No change in the view v1 definition and v2 state.
SHOW TABLES;
Tables_in_test
v1
v2
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
# Binlog for failed alter view is not written.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
# On a transaction commit, DD object of view is stored and binlog
# event for view v1 is written.
ALTER VIEW v1 AS SELECT 1 as a1, 2 AS a2;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `a1`,2 AS `a2` utf8mb4 utf8mb4_0900_ai_ci
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SHOW TABLES;
Tables_in_test
v1
v2
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 as a1, 2 AS a2
#
# Test case to verify if DROP VIEW statement is atomic/crash safe.
#
SET SESSION DEBUG="+d,simulate_drop_view_failure";
DROP VIEW v1;
ERROR HY000: Unknown error
SET SESSION DEBUG="-d,simulate_drop_view_failure";
# DD object for view v1 is not dropped and binlog event for view v1
# is not written in an error/ia rollback scenarios.
# No change in the view v1 definition and v2 state.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `a1`,2 AS `a2` utf8mb4 utf8mb4_0900_ai_ci
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SHOW TABLES;
Tables_in_test
v1
v2
# Binlog for failed drop view is not written.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 as a1, 2 AS a2
# On a transaction commit, DD object of view is dropped and binlog
# event for view v1 is written.
DROP VIEW v1;
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`1` AS `1` from `v1` utf8mb4 utf8mb4_0900_ai_ci
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SHOW TABLES;
Tables_in_test
v2
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 as a1, 2 AS a2
binlog.000001 # Query # # use `test`; DROP VIEW v1
# v1 view does not exists so only binlog is written in this case.
DROP VIEW IF EXISTS v1;
Warnings:
Note 1051 Unknown table 'test.v1'
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 as a1, 2 AS a2
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; DROP VIEW IF EXISTS v1
CREATE VIEW v3 AS SELECT 1;
CREATE VIEW v4 AS SELECT 1;
CREATE TABLE t1(f1 int);
DROP VIEW t1, v3, v4;
ERROR HY000: 'test.t1' is not VIEW
# No binlog event is written in statement failure because of table
# usage in the statement.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 as a1, 2 AS a2
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; DROP VIEW IF EXISTS v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 int)
# Existing views v4 & v5 are dropped and binlog is written in this
# case.
DROP VIEW IF EXISTS v3, v4, v5;
Warnings:
Note 1051 Unknown table 'test.v5'
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM v1
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1
binlog.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 as a1, 2 AS a2
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; DROP VIEW IF EXISTS v1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS SELECT 1
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 int)
binlog.000001 # Query # # use `test`; DROP VIEW IF EXISTS v3, v4, v5
DROP VIEW v2;
DROP TABLE t1;
#########################################################################
# #
# E. These test cases are added in order to test error code path that is#
# not covered by existing test cases, focusing gcov test coverage. #
# #
#########################################################################
SET @orig_lock_wait_timeout= @@global.lock_wait_timeout;
SET GLOBAL lock_wait_timeout= 1;
#
# Test case to cover failure of method to update view/stored function
# referencing views column metadata and status.
#
CREATE TABLE t1(f1 INT);
CREATE FUNCTION f() RETURNS INT return 1;
CREATE VIEW v1 AS SELECT 2 as f2;
CREATE VIEW v2 AS SELECT f() as f1, v1.f2 FROM v1;
include/show_binlog_events.inc
connection default;
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT f() as f1, v1.f2 FROM v1
connection default;
connection default;
# Acquire metadata lock on view v2.
SET DEBUG_SYNC="rm_table_no_locks_before_delete_table SIGNAL drop_func WAIT_FOR go";
DROP TABLE IF EXISTS t1, v2;;
connect con1, localhost, root,,;
SET DEBUG_SYNC="now WAIT_FOR drop_func";
# Drop function "f" fails as lock acquire on view "v2" referencing "f"
# times out.
DROP FUNCTION f;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
include/show_binlog_events.inc
connection con1;
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT f() as f1, v1.f2 FROM v1
connection con1;
connection con1;
# Drop function "f" fails as lock acquire on view "v2" referencing "f"
# times out.
DROP VIEW v1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
include/show_binlog_events.inc
connection con1;
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT f() as f1, v1.f2 FROM v1
connection con1;
connection con1;
SET DEBUG_SYNC="now SIGNAL go";
connection default;
Warnings:
Note 1051 Unknown table 'test.v2'
# Status of view "v2" is set to invalid in the drop view statement.
DROP VIEW v1;
# Acquire metadata lock on stored function "f".
SET DEBUG_SYNC='after_acquiring_mdl_lock_on_routine SIGNAL drop_view WAIT_FOR go';
DROP FUNCTION f;;
connection con1;
SET DEBUG_SYNC='now WAIT_FOR drop_view';
# Create view "v1" fails as column metadata update and status of
# referencing view "v2" fails because lock acquire timeout on "f".
CREATE VIEW v1 AS SELECT 2 as f2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC="now SIGNAL go";
connection default;
CREATE VIEW v1 AS SELECT 2 as f2;
# Acquire metadata lock on view "v1".
LOCK TABLES v1 WRITE;
connection con1;
# Create function "f" fails as column metadata update and status of view
# referencing view "v2" fails because lock acquire timeout on view "v1".
CREATE FUNCTION f() RETURNS INT return 1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection default;
SET DEBUG_SYNC='RESET';
UNLOCK TABLES;
disconnect con1;
DROP VIEW v1, v2;
SET GLOBAL lock_wait_timeout= @orig_lock_wait_timeout;
# Binlog should not contain any event from failed statements.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT f() as f1, v1.f2 FROM v1
binlog.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1`,`v2` /* generated by server */
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; DROP FUNCTION f
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; DROP VIEW v1, v2
#
# Test case to cover stored routine and view object acquire method
# failure.
#
CREATE FUNCTION f1() RETURNS INT return 1;
SET SESSION DEBUG='+d,fail_while_acquiring_dd_object';
CREATE FUNCTION f1() RETURNS INT return 1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ALTER FUNCTION f1 COMMENT "wl9173";
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
CREATE VIEW v1 AS SELECT 1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
DROP VIEW v1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET SESSION DEBUG='-d,fail_while_acquiring_dd_object';
DROP FUNCTION f1;
SET SESSION DEBUG='+d,fail_while_acquiring_routine_schema_obj';
CREATE FUNCTION f1() RETURNS INT return 1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET SESSION DEBUG='-d,fail_while_acquiring_routine_schema_obj';
CREATE VIEW v1 AS SELECT 2 as f2;
SET SESSION DEBUG='+d,fail_while_acquiring_view_obj';
DROP VIEW v1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET SESSION DEBUG='-d,fail_while_acquiring_view_obj';
DROP VIEW v1;
# Binlog should not contain any event from failed statements.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT f() as f1, v1.f2 FROM v1
binlog.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1`,`v2` /* generated by server */
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; DROP FUNCTION f
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; DROP VIEW v1, v2
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; DROP FUNCTION f1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; DROP VIEW v1
#
# Test case to cover store routine drop object method failure.
#
CREATE FUNCTION f1() RETURNS INT return 1;
SET DEBUG='+d,fail_while_dropping_dd_object';
DROP FUNCTION f1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG='-d,fail_while_dropping_dd_object';
DROP FUNCTION f1;
# Binlog should not contain any event from failed statements.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog.000001 # Query # # use `test`; CREATE TABLE t1(f1 INT)
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT f() as f1, v1.f2 FROM v1
binlog.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1`,`v2` /* generated by server */
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; DROP FUNCTION f
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; DROP VIEW v1, v2
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; DROP FUNCTION f1
binlog.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 2 as f2
binlog.000001 # Query # # use `test`; DROP VIEW v1
binlog.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int
return 1
binlog.000001 # Query # # use `test`; DROP FUNCTION f1
#########################################################################
|