Skip to content

Commit

Permalink
workload/schemachange: return error when a table has no columns
Browse files Browse the repository at this point in the history
Previously, unexpected syntax errors would occur if the workload
attempted to create an index on a table with no columns.
For example, the workload would generate a statements such as
`CREATE INDEX index2 ON table1 ()`, which are syntactically
invalid. This change updates the function `getTableColumns` to
return an error if a table has no columns to use when creating
an index. The workload will try to generate another operation
when it sees this error.

Release note: None
  • Loading branch information
jayshrivastava committed Dec 21, 2020
1 parent f6528c5 commit 4e31a6a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,9 @@ func (og *operationGenerator) getTableColumns(
if err := rows.Err(); err != nil {
return nil, err
}
if len(ret) == 0 {
return nil, pgx.ErrNoRows
}
for i := range ret {
c := &ret[i]
c.typ, err = og.typeFromTypeName(tx, typNames[i])
Expand Down

0 comments on commit 4e31a6a

Please sign in to comment.