Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
45621: sql: allow inverted indexes on mixed-case cols r=jordanlewis a=jordanlewis

Closes cockroachdb#42944.

Previously, a bug prevented creation of inverted indexes on columns with
mixed-case identifiers. Now, the bug is fixed.

Release note (bug fix): it is now possible to create inverted indexes on
columns whose names are mixed-case.

Co-authored-by: Jordan Lewis <[email protected]>
  • Loading branch information
craig[bot] and jordanlewis committed Mar 3, 2020
2 parents 8ffade8 + bbac108 commit b0be21a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ func (sc *SchemaChanger) validateInvertedIndexes(
row, err := ie.QueryRowEx(ctx, "verify-inverted-idx-count", txn,
sqlbase.InternalExecutorSessionDataOverride{},
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
19 changes: 13 additions & 6 deletions pkg/sql/logictest/testdata/logic_test/inverted_index
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ statement ok
CREATE TABLE c (
id INT PRIMARY KEY,
foo JSON,
bar JSON,
"bAr" JSON,
"qUuX" JSON,
INVERTED INDEX (foo),
INVERTED INDEX (bar),
FAMILY "primary" (id, foo, bar)
INVERTED INDEX ("bAr"),
FAMILY "primary" (id, foo, "bAr", "qUuX")
)

query TT
Expand All @@ -38,13 +39,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 b0be21a

Please sign in to comment.