Integer division by -1 on INT64_MIN raises a misclassified floating-point exception (22P01) instead of bigint out of range
维护者通常 2 天内回复
评估
调研方向
从复现开始:在 LOAD 'age' 之后运行 Cypher 查询 RETURN (-9223372036854775807 - 1) / -1,观察 22P01 浮点数错误。在 AGE 的 C 语言 agtype 算术代码中找到整数除法,这里发生了未经检查的除法。与 PostgreSQL 的 int8.c 中的 int84div 进行比较,在这种情况下它会抛出 22003 bigint out of range。完成的标准是:Cypher 查询因 bigint 超出范围错误而失败,并且其他算术行为保持不变。
由索引模型根据 Issue 内容生成。
描述
AGE Version: Apache AGE extension 1.8.0 on PostgreSQL 18.6
Installation Method: Docker
API: Cypher
Steps to reproduce
LOAD 'age';
SET search_path = ag_catalog, public;
SELECT * FROM ag_catalog.create_graph('gdbug');
SELECT * FROM cypher('gdbug', $$ RETURN (-9223372036854775807 - 1) / -1 $$) AS (r agtype);
Expected behavior
+9223372036854775808 is outside the signed 64-bit range, so this should fail with a range error. The host database already does exactly that for the identical expression, and AGE inherits that behaviour everywhere except in its own agtype arithmetic:
SELECT (-9223372036854775807 - 1) / -1;
-- ERROR: 22003: bigint out of range
-- LOCATION: int84div, int8.c:986
Actual behavior
The Cypher path does not report a range error. The integer division is executed unchecked; the hardware raises #DE/SIGFPE, and PostgreSQL's signal handler converts it into a floating-point exception:
ERROR: 22P01: floating-point exception
DETAIL: An invalid floating-point operation was signaled. This probably means
an out-of-range result or an invalid operation, such as division by zero.
LOCATION: FloatExceptionHandler, postgres.c:3077
- 主要语言
- C
- 星标
- 4.9k
- 派生
- 532
- 平均合并
- 9 天 18 小时
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/age 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 72/100
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 50/100
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
DaveGamble/cJSON#1100 ·
-
area:runtime-vm
难度 2/5 1-3 小时 新手友好度 72/100
InauguralSystems/EigenScript#1748 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
leanprover/lean4#15677 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
wasm-micro-runtime/wasm-micro-runtime#5159 ·
维护者通常 7 天内回复