Repository navigation
Conversation
Long source names can alias on PostgreSQL while remaining distinct in Postgrex, allowing cached writes to target the wrong table. Keep generated keys within the limit; see elixir-ecto#751.
Hash-only names hide the table in statement-name-only diagnostics. Retain an ASCII hint without reintroducing server-side truncation. Keep caller-supplied names and names already within the limit unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ecto's operation prefix and suffix can make generated statement names exceed PostgreSQL's default 63-byte limit, even for valid table names. Postgrex caches the full name, so different client keys can alias one server statement on a connection, causing parameter errors or silent wrong-table writes.
Based on the diagnosis and fix in elixir-ecto/ecto_sql#751 by aiboupeter. Explicit overlong
cache_statementoverrides remain outside scope.Security Implications
Prevents unintended-table writes from generated-name aliasing; database permissions are unchanged.
How to Test
Local results with locked dependencies: Elixir 1.20.5, OTP 29, PostgreSQL 18.6, using an isolated database.
ECTO_ADAPTER=pg mix test integration_test/pg/prepare_test.exs --seed 0: 5 passed; the ordinary and bulk destination assertions fail on the base.mix test --seed 0: 707 passed.ECTO_ADAPTER=pg mix test --seed 0: 499 passed, 8 excluded.Compiler warnings and storage-fixture stderr were emitted. Older runtime/database combinations and MySQL/MSSQL integration were not run locally. GitHub CI currently reports no checks.