fix: verify server snapshots and recover whole migration sessions (#3)
This commit is contained in:
1 parent
3d4101ecc0
commit
8569871a17
29 files changed
+1923
-133
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package mariadb
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSnapshotTriggerReferences(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name, body, mode string
|
||||
fail bool
|
||||
}{
|
||||
{"local", "INSERT INTO audit VALUES (NEW.id, OLD.value)", "", false},
|
||||
{"local qualified", "UPDATE `example`.`audit` SET id=NEW.id", "", false},
|
||||
{"alias", "SELECT 1 FROM audit a WHERE a.id=OLD.id", "", false},
|
||||
{"literal", "INSERT INTO audit VALUES ('example.com', '$.field', 'UPDATE other.audit')", "", false},
|
||||
{"comment", "/* UPDATE other.audit */ INSERT INTO audit VALUES (NEW.id)", "", false},
|
||||
{"external write", "UPDATE other.audit SET id=NEW.id", "", true},
|
||||
{"external insert", "INSERT INTO `other`.`audit` VALUES (NEW.id)", "", true},
|
||||
{"ANSI external", `UPDATE "other"."audit" SET id=NEW.id`, "ANSI_QUOTES", true},
|
||||
{"external function", "SET NEW.value=other.example(NEW.value)", "", true},
|
||||
{"routine", "CALL example.change_rows()", "", true},
|
||||
{"executable", "/*!50000 UPDATE other.audit SET id=1 */", "", true},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := validateSnapshotTriggerReferences(snapshotTrigger{Name: "example", Body: tt.body, SQLMode: tt.mode}, "example")
|
||||
if (err != nil) != tt.fail {
|
||||
t.Fatalf("error=%v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user