yugabyte/yugabyte-db

[YSQL] Indexes created on Numeric type are inconsistent

开放

#28,967 创建于 2025年10月16日

 (1 条评论) (0 个反应) (0 位负责人)C (1,003 个派生)batch import
area/ysqlgood first issuekind/bugpriority/low

仓库指标

星标
 (8,229 个星标)
PR 合并指标
 (平均合并 17天 21小时) (30 天内合并 92 个 PR)

描述

Jira Link: DB-18707

Description

Version - 2.29.0.0-b43 Steps -

CREATE TABLE test (id SERIAL PRIMARY KEY, c_numeric NUMERIC(12,4));
INSERT INTO test (c_numeric) SELECT (random()*1000)::numeric(12,4) FROM generate_series(1, 10000);
CREATE INDEX test_idx ON test ((c_numeric*2)) ;
select yb_index_check('test_idx'::regclass);

Error -

ERROR:  inconsistent index row due to binary mismatch of key attribute
DETAIL:  index: 'test_idx', ybbasectid: '\x4700b3488000059b2121', index attnum: 1

However, If we do not use expression the index is found consistent -

CREATE TABLE test (id SERIAL PRIMARY KEY, c_numeric NUMERIC(12,4));
INSERT INTO test (c_numeric) SELECT (random()*1000)::numeric(12,4) FROM generate_series(1, 10000);
CREATE INDEX test_idx ON test (c_numeric) ;
select yb_index_check('test_idx'::regclass);

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.

贡献者指南