Skip to content

Commit

Permalink
Strip double quotes from index names
Browse files Browse the repository at this point in the history
Postgres stores index names with uppercase characters in the `pg_index`
catalog using the quoted version of the name. For example:

```
"idx_USERS_name"
```

whereas a lowercase index name would be stored as:

```
idx_users_name
```

This is different to how other object types are stored in their
respective catalogs. For example, table names are stored in the
`pg_class` catalog without quotes, regardless of whether they contain
uppercase characters.
  • Loading branch information
andrew-farries committed May 16, 2024
1 parent 173cea7 commit 73cf6c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ BEGIN
)), '{}'::json)
FROM (
SELECT
reverse(split_part(reverse(pi.indexrelid::regclass::text), '.', 1)) as name,
replace(reverse(split_part(reverse(pi.indexrelid::regclass::text), '.', 1)), '"', '') as name,
pi.indisunique,
array_agg(a.attname) AS columns
FROM pg_index pi
Expand Down

0 comments on commit 73cf6c8

Please sign in to comment.