Skip to content

Commit

Permalink
Merge pull request #45678 from jordanlewis/backport19.1-45621
Browse files Browse the repository at this point in the history
release-19.1: sql: allow inverted indexes on mixed-case cols
  • Loading branch information
jordanlewis authored Mar 4, 2020
2 parents 1fcf710 + 49811a2 commit d651c17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ func (sc *SchemaChanger) validateInvertedIndexes(
col := idx.ColumnNames[0]
row, err := evalCtx.InternalExecutor.QueryRow(ctx, "verify-inverted-idx-count", txn,
fmt.Sprintf(
`SELECT coalesce(sum_int(crdb_internal.json_num_index_entries(%s)), 0) FROM [%d AS t]`,
`SELECT coalesce(sum_int(crdb_internal.json_num_index_entries(%q)), 0) FROM [%d AS t]`,
col, tableDesc.ID,
),
)
Expand Down
17 changes: 12 additions & 5 deletions pkg/sql/logictest/testdata/logic_test/inverted_index
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ statement ok
CREATE TABLE c (
id INT PRIMARY KEY,
foo JSON,
bar JSON,
"bAr" JSON,
"qUuX" JSON,
INVERTED INDEX (foo),
INVERTED INDEX (bar)
INVERTED INDEX ("bAr")
)

query TT
Expand All @@ -39,13 +40,19 @@ SHOW CREATE TABLE c
c CREATE TABLE c (
id INT8 NOT NULL,
foo JSONB NULL,
bar JSONB NULL,
"bAr" JSONB NULL,
"qUuX" JSONB NULL,
CONSTRAINT "primary" PRIMARY KEY (id ASC),
INVERTED INDEX c_foo_idx (foo),
INVERTED INDEX c_bar_idx (bar),
FAMILY "primary" (id, foo, bar)
INVERTED INDEX "c_bAr_idx" ("bAr"),
FAMILY "primary" (id, foo, "bAr", "qUuX")
)

# Regression test for #42944: make sure that mixed-case columns can be
# inverted indexed.
statement ok
CREATE INVERTED INDEX ON c("qUuX")

statement error indexing more than one column with an inverted index is not supported
CREATE TABLE d (
id INT PRIMARY KEY,
Expand Down

0 comments on commit d651c17

Please sign in to comment.