Skip to content

[YSQL] Error/crash on complex row compare #29942

@jasonyb

Description

@jasonyb

Jira Link: DB-19798

Description

Commit afc424d introduces illogical code scan_plan->bind_key_attnums[current->sk_attno], causing errors and segfaults. For example,

create table t4(v1 int, a uuid, v2 int, b timestamptz, PRIMARY KEY(b asc, v1, a asc));
insert into t4 (a, b, v1) values ('00000000-0000-0000-0000-000000000000', '2021-01-01 00:00:00', 1);
insert into t4 (a, b, v1) values ('00000000-0000-0000-0000-000000000001', '2021-01-01 00:00:00', 2);
explain (costs off) select * from t4 where (b, a) >= ('2021-01-01 00:00:00', '00000000-0000-0000-0000-000000000001');

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using t4_pkey on t4
   Index Cond: (ROW(b, a) >= ROW('2021-01-01 00:00:00-08'::timestamp with time zone, '00000000-0000-0000-0000-000000000001'::uuid))
(2 rows)

select * from t4 where (b, a) >= ('2021-01-01 00:00:00', '00000000-0000-0000-0000-000000000001');

ERROR:  invalid system attribute number 0

If you have a complicated schema/query involving row compare, you may be affected.

Prior versions up to 2.20 should be affected, but backporting to 2.20 can be deprioritized as it's not very active and this is an edge case.

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions