Handle Raft commands missing Parameterized values
This allows this code to run with Raft logs from previous versions.
@@ -1121,12 +1121,18 @@ func subCommandToStatements(d *databaseSub) []sql.Statement {
stmts := make([]sql.Statement, len(d.Queries))
for i := range d.Queries {
stmts[i].Query = d.Queries[i]
- stmts[i].Parameters = make([]gosql.Value, len(d.Parameters[i]))
+ // Support backwards-compatibility, since previous versions didn't
+ // have Parameters in Raft commands.
+ if len(d.Parameters) == 0 {
+ stmts[i].Parameters = make([]gosql.Value, 0)
+ } else {
+ stmts[i].Parameters = make([]gosql.Value, len(d.Parameters[i]))
for j := range d.Parameters[i] {
stmts[i].Parameters[j] = d.Parameters[i][j]
}
}
+ }
return stmts
}
