| From: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
|---|---|
| To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | hlinnaka(at)iki(dot)fi |
| Subject: | Fix assert failure in composite type dependency check for index expr |
| Date: | 2026-11-25 13:00:33 |
| Message-ID: | 1ffe1c34-4518-4305-bb8c-9b162da6c453@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
While reading through the recent security fixes, I noticed that commit
d98d99ba17b updated recordDependencyOnSingleRelExpr() and
CheckUsageOnTypesInSingleRelExpr() to include the expression's result
type, but missed CheckTypeDependencyInSingleRelExpr().
When an index uses a storage key type different from the expression's
return type (such as hash or GIN array_ops indexes), the column check in
check_composite_type_dependency() does not match, and
CheckTypeDependencyInSingleRelExpr() returns false, hitting Assert(false):
CREATE TYPE atcomp AS (a numeric);
CREATE TABLE atref (c int);
CREATE FUNCTION atfunc(numeric) RETURNS atcomp IMMUTABLE
LANGUAGE plpgsql AS $$BEGIN RETURN ('('||$1||')')::atcomp; END$$;
CREATE INDEX atref_hash_idx ON atref USING hash (atfunc(c));
ALTER TYPE atcomp ALTER ATTRIBUTE a TYPE bigint;
-- TRAP: failed Assert("false"), File: "tablecmds.c", Line: 7490
(The same Assert(false) can also be reached via get_rels_with_domain()
during ALTER DOMAIN ... ADD CONSTRAINT / SET NOT NULL when a GIN, GiST,
or BRIN expression index returns a container over the domain. In
non-cassert builds, execution falls through to
report_type_used_in_expr() and still rejects the ALTER.)
Attached is a patch teaching CheckTypeDependencyInSingleRelExpr() to
check exprType() in the same way as recordDependencyOnSingleRelExpr(),
and passing indrelid rather than the index's own OID when checking
indexprs and indpred to match index_create(). Since d98d99ba17b was
backpatched, this affects 14 through master.
--
Best Regards,
Zhijie Hou
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-composite-type-dependency-check-for-index-exp.patch | text/plain | 7.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Jim Jones | 2026-11-25 12:55:24 | Re: OOM kill in xmlelement() with large arrays |