yugabyte/yugabyte-db

[YSQL] Indexes created on Numeric type are inconsistent

Open

#28,967 opened on Oct 16, 2025

View on GitHub
 (1 comment) (0 reactions) (0 assignees)C (8,229 stars) (1,003 forks)batch import
area/ysqlgood first issuekind/bugpriority/low

Description

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.

Contributor guide