Skip to content

fix(postgrest): apply per-tenant db_max_rows on GET/RPC reads#10

Merged
Chat2DB-Pro merged 1 commit into
OtterMind:mainfrom
oopswoo3:fix/postgrest-db-max-rows
Jun 18, 2026
Merged

fix(postgrest): apply per-tenant db_max_rows on GET/RPC reads#10
Chat2DB-Pro merged 1 commit into
OtterMind:mainfrom
oopswoo3:fix/postgrest-db-max-rows

Conversation

@oopswoo3

Copy link
Copy Markdown
Contributor

论证:这是缺陷,有必要修

  1. 配置链路完整,执行链路断裂database_configs.db_max_rows 有表字段、新项目默认 1000PostgRESTConfig 注释为 Maximum number of rows returned,但 QueryPlanner 从未读取。
  2. 与 PostgREST 语义不符 — 官方 db-max-rows 对 GET 无 Range 时施加默认上限,并对客户端过大的 Range 封顶;当前无 Range 时可能无界 SELECT
  3. 有实际风险 — 大表 REST 查询可拖垮租户 DB / 应用内存;初始化写死 1000 说明作者预期存在上限。
  4. 不是刻意禁用 — 无 feature flag、无「暂未实现」注释;Preferences.maxRows 字段存在但未接线,属于半成品。

本 PR 有意不做Prefer: max-rowscount=estimated 阈值、mutation 路径(PostgREST 亦不对 POST/PATCH/DELETE 套 db-max-rows)。

Summary

  • 新增 PostgrestRowLimitResolver,合并 db_max_rows 与 Range/limit
  • QueryPlanner 的 GET / RPC 读路径通过 MultiTenancyContext.getDatabaseConfig() 应用上限
  • db_max_rows 为 null 或 ≤0 时不施加默认 LIMIT(尊重可空列)

Test plan

  • mvn test -Dtest=PostgrestRowLimitResolverTest,QueryPlannerTest

Wire database_configs.db_max_rows into QueryPlanner so unbounded REST reads
get a default LIMIT and client Range requests are capped, matching PostgREST.
@Chat2DB-Pro Chat2DB-Pro merged commit 23a3f98 into OtterMind:main Jun 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants