From 5eb35aafb9dfbc33da2f6d7cd5f47511751ee333 Mon Sep 17 00:00:00 2001 From: Faizan Qazi Date: Mon, 8 Aug 2022 09:38:41 -0400 Subject: [PATCH] sql/randgen: avoid invalid inverted indexes in CREATE TABLE Previously, the create table made via the randgen component could create invalid CREATE TABLE statements where the last columns of an inverted index were descending. This could lead to unexpected failures in certain workloads, which expected valid statements from this components. To address this, this patch stops randgen from generating CREATE table statements with invalid inverted indexes. Release note: None --- pkg/sql/randgen/schema.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/sql/randgen/schema.go b/pkg/sql/randgen/schema.go index 2d6d2f6de08d..587e21b3a36d 100644 --- a/pkg/sql/randgen/schema.go +++ b/pkg/sql/randgen/schema.go @@ -189,6 +189,10 @@ func RandCreateTableWithColumnIndexNumberGenerator( if foundOverlap { continue } + // Inverted indexes can only be ascending on the last column. + if col.Direction == tree.Descending { + continue + } } // Make forward indexes unique 50% of the time. Inverted indexes cannot // be unique.