Skip to content

Fix sqlancer#1249: Postgres REINDEX now generate only one index name per statement #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

albertZhangTJ
Copy link
Collaborator

In Postgres, each REINDEX statement can only work on one index, as can be seen here.

The previous edition will instead generate all index names, concatenated without delimiter.

@@ -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
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants