MCPcopy Create free account
hub / github.com/Percona-Lab/mysql_random_data_load / getTriggers

Function getTriggers

tableparser/tableparser.go:339–361  ·  view source on GitHub ↗
(db *sql.DB, schema, tableName string)

Source from the content-addressed store, hash-verified

337}
338
339func getTriggers(db *sql.DB, schema, tableName string) ([]Trigger, error) {
340 query := fmt.Sprintf("SHOW TRIGGERS FROM `%s` LIKE '%s'", schema, tableName)
341 rows, err := db.Query(query)
342 if err != nil {
343 return nil, err
344 }
345 defer rows.Close()
346
347 triggers := []Trigger{}
348
349 for rows.Next() {
350 var t Trigger
351 err := rows.Scan(&t.Trigger, &t.Event, &t.Table, &t.Statement, &t.Timing,
352 &t.Created, &t.SQLMode, &t.Definer, &t.CharacterSetClient, &t.CollationConnection,
353 &t.DatabaseCollation)
354 if err != nil {
355 return nil, fmt.Errorf("cannot read trigger: %s", err)
356 }
357 triggers = append(triggers, t)
358 }
359
360 return triggers, nil
361}
362
363func constraintsAsMap(constraints []Constraint) map[string]*Constraint {
364 m := make(map[string]*Constraint)

Callers 2

TestGetTriggersFunction · 0.85
NewTableFunction · 0.85

Calls 1

ScanMethod · 0.80

Tested by 1

TestGetTriggersFunction · 0.68