@@ -3421,6 +3421,135 @@ end;
3421
3421
},
3422
3422
},
3423
3423
},
3424
+
3425
+ {
3426
+ Name : "insert trigger with stored procedure with deletes" ,
3427
+ SetUpScript : []string {
3428
+ "create table t (i int);" ,
3429
+ "create table t1 (j int);" ,
3430
+ "insert into t1 values (1);" ,
3431
+ "create table t2 (k int);" ,
3432
+ "insert into t2 values (1);" ,
3433
+ "create table t3 (l int);" ,
3434
+ "insert into t3 values (1);" ,
3435
+ "create table t4 (m int);" ,
3436
+ `
3437
+ create procedure proc(x int)
3438
+ begin
3439
+ delete from t2 where k = (select j from t1 where j = x);
3440
+ update t3 set l = 10 where l = x;
3441
+ insert into t4 values (x);
3442
+ end;
3443
+ ` ,
3444
+ `
3445
+ create trigger trig before insert on t
3446
+ for each row
3447
+ begin
3448
+ call proc(new.i);
3449
+ end;
3450
+ ` ,
3451
+ },
3452
+ Assertions : []ScriptTestAssertion {
3453
+ {
3454
+ Query : "insert into t values (1);" ,
3455
+ Expected : []sql.Row {
3456
+ {types .NewOkResult (1 )},
3457
+ },
3458
+ },
3459
+ {
3460
+ Query : "select * from t;" ,
3461
+ Expected : []sql.Row {
3462
+ {1 },
3463
+ },
3464
+ },
3465
+ {
3466
+ Query : "select * from t1;" ,
3467
+ Expected : []sql.Row {
3468
+ {1 },
3469
+ },
3470
+ },
3471
+ {
3472
+ Query : "select * from t2;" ,
3473
+ Expected : []sql.Row {},
3474
+ },
3475
+ {
3476
+ Query : "select * from t3;" ,
3477
+ Expected : []sql.Row {
3478
+ {10 },
3479
+ },
3480
+ },
3481
+ {
3482
+ Query : "select * from t4;" ,
3483
+ Expected : []sql.Row {
3484
+ {1 },
3485
+ },
3486
+ },
3487
+ },
3488
+ },
3489
+
3490
+ {
3491
+ Name : "delete trigger with stored procedure with deletes" ,
3492
+ SetUpScript : []string {
3493
+ "create table t (i int);" ,
3494
+ "insert into t values (1)" ,
3495
+ "create table t1 (j int);" ,
3496
+ "insert into t1 values (1);" ,
3497
+ "create table t2 (k int);" ,
3498
+ "insert into t2 values (1);" ,
3499
+ "create table t3 (l int);" ,
3500
+ "insert into t3 values (1);" ,
3501
+ "create table t4 (m int);" ,
3502
+ `
3503
+ create procedure proc(x int)
3504
+ begin
3505
+ delete from t2 where k = (select j from t1 where j = x);
3506
+ update t3 set l = 10 where l = x;
3507
+ insert into t4 values (x);
3508
+ end;
3509
+ ` ,
3510
+ `
3511
+ create trigger trig before delete on t
3512
+ for each row
3513
+ begin
3514
+ call proc(old.i);
3515
+ end;
3516
+ ` ,
3517
+ },
3518
+ Assertions : []ScriptTestAssertion {
3519
+ {
3520
+ Query : "delete from t where i = 1;" ,
3521
+ Expected : []sql.Row {
3522
+ {types .NewOkResult (1 )},
3523
+ },
3524
+ },
3525
+ {
3526
+ Query : "select * from t;" ,
3527
+ Expected : []sql.Row {},
3528
+ },
3529
+ {
3530
+ Query : "select * from t1;" ,
3531
+ Expected : []sql.Row {
3532
+ {1 },
3533
+ },
3534
+ },
3535
+ {
3536
+ Query : "select * from t2;" ,
3537
+ Expected : []sql.Row {},
3538
+ },
3539
+ {
3540
+ Query : "select * from t3;" ,
3541
+ Expected : []sql.Row {
3542
+ {10 },
3543
+ },
3544
+ },
3545
+ {
3546
+ Query : "select * from t4;" ,
3547
+ Expected : []sql.Row {
3548
+ {1 },
3549
+ },
3550
+ },
3551
+ },
3552
+ },
3424
3553
}
3425
3554
3426
3555
var TriggerCreateInSubroutineTests = []ScriptTest {
0 commit comments