Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Integer division by -1 on INT64_MIN raises a misclassified floating-point exception (22P01) instead of bigint out of range

未关闭 适合新手
#2,590 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@sean0407 已经在做这个了。

开始于 2026年10月11日。

  • #2591 来自 @sean0407 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c, postgresql
领域
database

调研方向

从复现开始:在 LOAD 'age' 之后运行 Cypher 查询 RETURN (-9223372036854775807 - 1) / -1,观察 22P01 浮点数错误。在 AGE 的 C 语言 agtype 算术代码中找到整数除法,这里发生了未经检查的除法。与 PostgreSQL 的 int8.c 中的 int84div 进行比较,在这种情况下它会抛出 22003 bigint out of range。完成的标准是:Cypher 查询因 bigint 超出范围错误而失败,并且其他算术行为保持不变。

由索引模型根据 Issue 内容生成。

描述

bug

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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/age 的其他 Issue

查看 apache/age 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。