Skip to content

Commit 7625d9f

Browse files
craig[bot]Vidit Bhat
andcommitted
Merge #144455
144455: drt: add support for CREATE INDEX USING HASH in add-index operation r=shailendra-patel a=vidit-bhat Previously, the `add-index` operation always created default index and did not test hash indexes. This patch introduces a 50% random chance of adding `USING HASH` to the `CREATE INDEX` statement. Epic: none Fixes: #138411 Release note: None Co-authored-by: Vidit Bhat <[email protected]>
2 parents 3227bce + b88c2fd commit 7625d9f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pkg/cmd/roachtest/operations/add_index.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,20 @@ WHERE
108108

109109
indexName := fmt.Sprintf("add_index_op_%d", rng.Uint32())
110110
o.Status(fmt.Sprintf("adding index to column %s in table %s.%s %s", colName, dbName, tableName, predicateClause))
111-
createIndexStmt := fmt.Sprintf("CREATE INDEX %s ON %s.%s (%s) %s", indexName, dbName, tableName, colName, predicateClause)
111+
// 50% chance to create a hash index
112+
indexUsingClause := ""
113+
if rng.Intn(2) == 0 {
114+
indexUsingClause = "USING HASH "
115+
}
116+
createIndexStmt := fmt.Sprintf("CREATE INDEX %s ON %s.%s %s(%s) %s",
117+
indexName,
118+
dbName,
119+
tableName,
120+
indexUsingClause,
121+
colName,
122+
predicateClause,
123+
)
124+
112125
_, err = conn.ExecContext(ctx, createIndexStmt)
113126
if err != nil {
114127
o.Fatal(err)

0 commit comments

Comments
 (0)