Skip to content

database_observability: fix schema_details collector to fetch column definitions with case sensitive table names#4872

Merged
fridgepoet merged 4 commits intomainfrom
shirley/case-sensitivity-table-detection
Nov 19, 2025
Merged

database_observability: fix schema_details collector to fetch column definitions with case sensitive table names#4872
fridgepoet merged 4 commits intomainfrom
shirley/case-sensitivity-table-detection

Conversation

@fridgepoet
Copy link
Contributor

@fridgepoet fridgepoet commented Nov 18, 2025

PR Description

This PR modifies the select column query to look up table name from pg_class and schema from pg_namespace, preserving any case sensitivity of the table name.

Previously, the lookup was done with a cast ::regclass. ::regclass lowercases unquoted identifiers, so if the table was created with mixed case, the lookup failed.

For example:
If a table like public.SomeMixedCaseName exists, then the previous code would fail with an error message like:
level=error msg="failed to get table definitions" component_path=/ component_id=database_observability.postgres.postgres_postgres_db collector=schema_details database=some_db schema=public err="pq: relation \"public.somemixedcasename\" does not exist"

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

)

func TestConnectionInfo(t *testing.T) {
defer goleak.VerifyNone(t)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three tests were failing locally if I ran them with -count=2 because of this. Just a drive-by improvement but can remove this from the PR if we prefer.

@fridgepoet fridgepoet marked this pull request as ready for review November 18, 2025 17:16
@fridgepoet fridgepoet requested review from a team as code owners November 18, 2025 17:16

- `loki.source.api` no longer drops request when relabel rules drops a specific stream. (@kalleep)

- (_Public Preview_) Additions to `database_observability.postgres` component:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this under Next > Bugfixes and with an Public Preview tag. Is that right?

@fridgepoet fridgepoet merged commit 7d0f15e into main Nov 19, 2025
41 checks passed
@fridgepoet fridgepoet deleted the shirley/case-sensitivity-table-detection branch November 19, 2025 11:28
dehaansa pushed a commit to madhub/alloy that referenced this pull request Dec 10, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2025
@grafana grafana unlocked this conversation Dec 19, 2025
@grafana grafana locked and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants