You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Define your query and handle the scanning of results
query := "SHOW CREATE TABLE " + targetTableName // Or use a dynamic query if needed
rows, err := db.Query(query)
if err != nil {
log.Fatal("Query failed: ", err)
return
}
defer rows.Close()
var vname, schema, ddl string
for rows.Next() {
// Handle case where source is a table and target is a view
err := rows.Scan(&vname, &schema, &ddl)
if err != nil {
log.Fatal("Scan failed: ", err)
return
}
// Case 1: Source is a table and target is a view
if isView(targetTableName) { // Function to check if target is a view
fmt.Println("Target is a view, returning DDL: ", ddl)
return // Or handle DDL output as required
}
// Case 2: Source and target don't match, just skip comparison
fmt.Println("Skipping comparison for this pair")
continue
}
// Check for any error after scanning all rows
if err := rows.Err(); err != nil {
log.Fatal("Rows iteration failed: ", err)
}
源库为表,目标库为视图,视图show create的时候会有4列,err := rs.Scan(&vname, &schema)需要4个入参,触发panic。
1)对于视图和表不一致,直接给出DDL?
2)跳过本次比对,继续后续的比对?
The text was updated successfully, but these errors were encountered: