yugabyte/yugabyte-db

[YSQL] Indexes created on Numeric type are inconsistent

Open

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

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)C (8,229 star) (1,003 fork)batch import
area/ysqlgood first issuekind/bugpriority/low

描述

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.

贡献者指南