Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/sqlancer/postgres/gen/PostgresReindexGenerator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sqlancer.postgres.gen;

import java.util.List;
import java.util.stream.Collectors;

import sqlancer.IgnoreMeException;
import sqlancer.Randomly;
Expand Down Expand Up @@ -39,7 +38,7 @@ public static SQLQueryAdapter create(PostgresGlobalState globalState) {
if (indexes.isEmpty()) {
throw new IgnoreMeException();
}
sb.append(indexes.stream().map(i -> i.getIndexName()).collect(Collectors.joining()));
sb.append(indexes.stream().skip(Randomly.getNotCachedInteger(0, indexes.size())).findFirst().map(i -> i.getIndexName()).orElse(""));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That looks quite complex. Could we use the Randomly class to get a random element of the indexes list and obtain the name of the index?

Also, I think we should investigate why this code currently does not trigger any bugs. There might be a more fundamental issue. For example, do we only generate one index at most?

break;
case TABLE:
sb.append("TABLE ");
Expand Down
Loading