Postgres function inspector reads wrong column ordinals: any schema with a function fails integrity inspection
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 92/100
调研方向
从 Migration/Nimblesite.DataProvider.Migration.Postgres/PostgresSupportSchemaInspector.cs 中的 functions 目录查询和读取器开始,将所选列与 GetString、IsDBNull 和 GetBoolean 使用的序号进行比较。针对包含 functions: 的所提供 schema 运行 DataProviderMigrate migrate --provider postgres,以重现完整性故障。当函数使用正确的所有者、搜索路径和 revoke 标志进行检查、迁移通过完整性验证,并且重新执行时不会产生任何更改时,即告完成。
由索引模型根据 Issue 内容生成。
描述
Bug
At refactor/deslop-ten-percent (3b4e356522affc61b466d8e87ef5232319c9d7a0), DataProviderMigrate migrate --provider postgres fails for every schema that has a function in the inspected schema (for example a top-level functions: entry):
Error: schema integrity inspection failed: Reading as 'System.String' is not supported for fields having DataTypeName 'boolean'
Error: migration apply failed: Schema integrity verification failed before commit
Cause
Migration/Nimblesite.DataProvider.Migration.Postgres/PostgresSupportSchemaInspector.cs: the functions catalog query selects, in order,
| ordinal | column |
|---|---|
| 7 | p.prosecdef |
| 8 | p.prosrc |
| 9 | owner.rolname AS owner_role |
| 10 | search_path_config |
| 11 | revoke_public_execute (boolean) |
| 12 | execute_roles |
but the reader uses
OwnerRole = reader.GetString(10),
SearchPath = ParseSearchPathConfig(reader.IsDBNull(11) ? null : reader.GetString(11)),
RevokePublicExecute = reader.GetBoolean(9),
so it reads a boolean as a string (and the owner as a boolean).
Fix
OwnerRole = reader.GetString(9),
SearchPath = ParseSearchPathConfig(reader.IsDBNull(10) ? null : reader.GetString(10)),
RevokePublicExecute = reader.GetBoolean(11),
Verified on PostgreSQL with a securityDefiner function declaring ownerRole, searchPath, executeRoles and revokePublicExecute: with the three ordinals corrected, migrate applies, passes the integrity check and replays as a no-op.
Repro
roles:
- { name: demo_writer, login: false }
functions:
- schema: demo
name: touch
returns: void
language: sql
volatility: volatile
securityDefiner: true
ownerRole: demo_writer
searchPath: [pg_catalog]
body: SELECT 1
Related gaps found at the same time
- Grants have no column lists (
GRANT SELECT (a, b) ON TABLE …); only table-level privileges can be declared, inspected and verified. - Roles have no way to receive a password (for example from an environment variable).
- A schema cannot be created by the migration (
CREATE SCHEMAmust be run by hand first).
- 主要语言
- C#
- 星标
- 68
- 派生
- 4
- 平均合并
- 50 分钟
- 30 天内合并 PR
- 2
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Nimblesite/DataProvider 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
Nimblesite/DataProvider#72 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
Nimblesite/DataProvider#121 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
Nimblesite/DataProvider#108 ·
维护者通常 1 天内回复
-
A check constraint the schema cannot name can never be retired, and keeps enforcing the old rule未关闭
难度 4/5 3-5 天 新手友好度 48/100
Nimblesite/DataProvider#107 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
Nimblesite/DataProvider#106 ·
维护者通常 1 天内回复
查看 Nimblesite/DataProvider 的全部 Issue
相似的 Issue
-
kronos:develop:queued priority:P0
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
nopSolutions/nopCommerce#8512 ·
维护者通常 4 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
modelcontextprotocol/csharp-sdk#2061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复