From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | nik(at)postgres(dot)ai |
Subject: | BUG #18244: Corruption in indexes involving whole-row expressions |
Date: | 2023-12-12 19:28:29 |
Message-ID: | 18244-8a7897de2acd5a08@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 18244
Logged by: Nikolay Samokhvalov
Email address: nik(at)postgres(dot)ai
PostgreSQL version: 16.1
Operating system: any
Description:
nik=# create index on t1 (hash_record(t1));
CREATE INDEX
Such an index can easily be corrupted, e.g.:
nik=# alter table t1 add column yo int default -1;
ALTER TABLE
Or if we just drop a column:
nik=# alter table t_n drop column c2;
ALTER TABLE
nik=# \d t_n
Table "public.t_n"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c1 | integer | | |
Indexes:
"t_n_hash_record_idx" btree (hash_record(t_n.*))
nik=# select * from t_n where hash_record(t_n) = hash_record(row(1, -1));
c1
----
1
(1 row)
nik=# select * from t_n where hash_record(t_n) = hash_record(row(1));
c1
----
(0 rows)
Or if index is unique:
nik=# select * from t_n;
c4
----
-1
-1
-1
(3 rows)
nik=# \d t_n
Table "public.t_n"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------------
c4 | integer | | | '-1'::integer
Indexes:
"t_n_hash_record_idx" UNIQUE, btree (hash_record(t_n.*))
nik=# reindex index t_n_hash_record_idx;
ERROR: could not create unique index "t_n_hash_record_idx"
DETAIL: Key (hash_record(t_n.*))=(385747274) is duplicated.
Proposal: prohibit the use of whole-row expression – as it is already done
for generated columns and produce a similar error ("cannot use whole-row
variable in column generation expression")
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2023-12-12 22:53:35 | Re: BUG #18244: Corruption in indexes involving whole-row expressions |
Previous Message | PG Bug reporting form | 2023-12-12 18:57:17 | BUG #18243: Ability to log in json format to stdout |