Re: cannot drop intarray extension

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: cannot drop intarray extension
Date: 2024-06-07 03:32:14
Message-ID: CACJufxHweUPLo4Y=HobOoEUoRTv27g7MB+SQo7Sq4N96ntfyEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 3, 2024 at 12:14 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
>
> ---- setup
> drop table if exist test__int cascade;
> create extension intarray;
>
> CREATE TABLE test__int( a int[] );
> CREATE INDEX text_idx on test__int using gist (a gist__intbig_ops(siglen = 1));
> drop extension intarray cascade;
> NOTICE: drop cascades to index text_idx
> 2024-06-03 11:53:32.629 CST [41165] ERROR: cache lookup failed for
> function 17758
> 2024-06-03 11:53:32.629 CST [41165] STATEMENT: drop extension intarray cascade;
> ERROR: cache lookup failed for function 17758
>
> ------------------------------------------------
> backtrace info:
> index_getprocinfo
> #0 index_opclass_options (indrel=0x7faeca727b58, attnum=1,
> attoptions=94372901674408, validate=false)
> at ../../Desktop/pg_src/src4/postgres/src/backend/access/index/indexam.c:1034
> #1 0x000055d4e63a79cb in RelationGetIndexAttOptions
> (relation=0x7faeca727b58, copy=false)
> at ../../Desktop/pg_src/src4/postgres/src/backend/utils/cache/relcache.c:5872
> #2 0x000055d4e639d72d in RelationInitIndexAccessInfo (relation=0x7faeca727b58)
> at ../../Desktop/pg_src/src4/postgres/src/backend/utils/cache/relcache.c:1569
> #3 0x000055d4e639c5ac in RelationBuildDesc (targetRelId=24582, insertIt=true)
> at ../../Desktop/pg_src/src4/postgres/src/backend/utils/cache/relcache.c:1207
> #4 0x000055d4e639e9ce in RelationIdGetRelation (relationId=24582)
> at ../../Desktop/pg_src/src4/postgres/src/backend/utils/cache/relcache.c:2115
> #5 0x000055d4e5a412fd in relation_open (relationId=24582, lockmode=8)
> at ../../Desktop/pg_src/src4/postgres/src/backend/access/common/relation.c:58
> #6 0x000055d4e5ae6a06 in index_open (relationId=24582, lockmode=8)
> at ../../Desktop/pg_src/src4/postgres/src/backend/access/index/indexam.c:137
> #7 0x000055d4e5be61b8 in index_drop (indexId=24582, concurrent=false,
> concurrent_lock_mode=false)
> at ../../Desktop/pg_src/src4/postgres/src/backend/catalog/index.c:2156
> ------------------------
> i guess it's because we first dropped the function g_intbig_options

in this context, the index "text_idx" has a normal dependency with pg_opclass.
but `drop extension intarray cascade;`,
CASCADE means that we drop the pg_opclass and pg_opclass's inner dependency
first, then drop the index.

while drop index (sub functions
RelationGetIndexAttOptions,index_opclass_options, index_getprocinfo)
requires that pg_opclass and its inner dependencies (namely
g_intbig_options, g_int_options) are not dropped first.

in deleteObjectsInList, under certain conditions trying to sort the to
be deleted object list
by just using sort_object_addresses seems to work,
but it looks like a hack.
maybe the proper fix would be in findDependentObjects.

Attachment Content-Type Size
v1-0001-trying-to-resolve-drop-extension-deletion-order.patch application/x-patch 8.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2024-06-07 03:38:06 Re: relfilenode statistics
Previous Message Andres Freund 2024-06-07 03:17:36 Re: relfilenode statistics