fix(postgrest): apply per-tenant db_max_rows on GET/RPC reads#10
Merged
Merged
Conversation
Wire database_configs.db_max_rows into QueryPlanner so unbounded REST reads get a default LIMIT and client Range requests are capped, matching PostgREST.
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.
论证:这是缺陷,有必要修
database_configs.db_max_rows有表字段、新项目默认1000、PostgRESTConfig注释为 Maximum number of rows returned,但QueryPlanner从未读取。db-max-rows对 GET 无 Range 时施加默认上限,并对客户端过大的 Range 封顶;当前无 Range 时可能无界SELECT。Preferences.maxRows字段存在但未接线,属于半成品。本 PR 有意不做:
Prefer: max-rows、count=estimated阈值、mutation 路径(PostgREST 亦不对 POST/PATCH/DELETE 套db-max-rows)。Summary
PostgrestRowLimitResolver,合并db_max_rows与 Range/limitQueryPlanner的 GET / RPC 读路径通过MultiTenancyContext.getDatabaseConfig()应用上限db_max_rows为 null 或 ≤0 时不施加默认 LIMIT(尊重可空列)Test plan
mvn test -Dtest=PostgrestRowLimitResolverTest,QueryPlannerTest