/
NikolayIvkin
/
sqlancer2
Обзор
Документация
Войти
/
NikolayIvkin
/
sqlancer2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/sqlancer/mysql/gen/MySQLDropIndex.java
51 строка
2 KB
Manuel Rigger
Fix JavaDoc issues
21 янв 2021, 01:47
21 янв 2021, 01:47
e118824
Код
Авторство
О чём код?
package sqlancer.mysql.gen; import sqlancer.IgnoreMeException; import sqlancer.Randomly; import sqlancer.common.query.ExpectedErrors; import sqlancer.common.query.SQLQueryAdapter; import sqlancer.mysql.MySQLGlobalState; import sqlancer.mysql.MySQLSchema.MySQLTable; /** * @see <a href="https://dev.mysql.com/doc/refman/8.0/en/drop-index.html">DROP INDEX Statement</a> */ public final class MySQLDropIndex { private MySQLDropIndex() { } // DROP INDEX index_name ON tbl_name // [algorithm_option | lock_option] ... // // algorithm_option: // ALGORITHM [=] {DEFAULT|INPLACE|COPY} // // lock_option: // LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE} public static SQLQueryAdapter generate(MySQLGlobalState globalState) { MySQLTable table = globalState.getSchema().getRandomTable(); if (!table.hasIndexes()) { throw new IgnoreMeException(); } StringBuilder sb = new StringBuilder(); sb.append("DROP INDEX "); sb.append(table.getRandomIndex().getIndexName()); sb.append(" ON "); sb.append(table.getName()); if (Randomly.getBoolean()) { sb.append(" ALGORITHM="); sb.append(Randomly.fromOptions("DEFAULT", "INPLACE", "COPY")); } if (Randomly.getBoolean()) { sb.append(" LOCK="); sb.append(Randomly.fromOptions("DEFAULT", "NONE", "SHARED", "EXCLUSIVE")); } return new SQLQueryAdapter(sb.toString(), ExpectedErrors.from("LOCK=NONE is not supported", "ALGORITHM=INPLACE is not supported", "Data truncation", "Data truncated for functional index", "A primary key index cannot be invisible")); } }