Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEtzT-004XY2-1E for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 19:09:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEtzR-004KFq-1y for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 19:09:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEtzR-004KFh-0b for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 19:09:01 +0000 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wEtzP-00000001xzI-0BD2 for pgsql-hackers@postgresql.org; Mon, 20 Apr 2026 19:09:00 +0000 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-6948da50eb5so505745eaf.1 for ; Mon, 20 Apr 2026 12:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776712139; cv=none; d=google.com; s=arc-20240605; b=DIV5l06wuEs9ejgfkJ9qy+5qI79zeHcQo7DjO246kOq0bEzQF62zdQAurVaZbIGHqy hyyYTqn9XwOqnMfVkw60usm2K+G91xKxKAdej5xcBsXDOdo0JXyKthvsyiPCSpM8gcj3 Q6Vys6J2VlvNlFarVyTMF5zgUVFrhli/mKuRxtUeEln7ArkX6j8dOoOASZ8XTgsF6m45 SXc9u4xGlREvtKmxhjCJ4w6ozHi3tVn02WP9dr8o+XmSAI/G8rLT5L1wRztim1zr2FD2 73T0EGjL9RPwFuLovq9EYqkuEKOwib/9lkASRBJEd588lsy5eWLIfUkwBftNE69k7agq zSqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=K53ny5L7FpS3N3CCZxy5e+UpFPXer/00U8PRdmewcwk=; fh=e8m8iQQa7m8z7kY1fdLbFjEy8wq2GItUCgCcjPZwxx8=; b=fukb84H5Y/LvzTkGxtEFBZgtvKY3XS+zJ1KiANnF49WiKxnxbvXrKpOVyr8FQpgZkY CpaQw+ycUxywhagelNZtF+zUSD9bLVvtL7W1k0dL77SVMaoBbM9BNiu6IX85LZX0Ixaq WEC5wg5RtqPI5xTfci7Cao8aTl8RW5esTv7IWx9ITbCtxeGbqvofYfTIL5aEVfOER+pf sNaLwk4k1ZhIJG9Gs9TvpIr4TMgr+hECaOJsti2Ias5aacm4Q0/nRnWKffwU1vwlvAxe g+peFfTplwQhGyMUZx5snllAqg2fG5acFanTSevuuLDgym0Uf5/a9vwCeNfBax7PVAsB sNSg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776712139; x=1777316939; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=K53ny5L7FpS3N3CCZxy5e+UpFPXer/00U8PRdmewcwk=; b=h5cGcpF0RYfBaOqhGCzbb+jY64hc9uArHytg4XmPlm+B3Bv5UB7XwGRhYd2cXLIZXo h9+iAnQFzrUsUBk6vpNILarGQCRtj3um2npjzPFhA5k4M6uoisxmUxSsEsZkdZA6pysy YyRqn5FkBPG9c3LzllykZM9bpu7IbFrbCLaAQz+s8uuVabELshi+o7Ed5ApoThvGFE2Z /s++IOMK1E4irsZAm6Pk/Upz7013k6hw/Jikx0lsfYRpmd7PD35L/ot7yFtJVW18hn8j kgwAjOtQD3vyd9GVv4Wt4OCuBFpZAkghiKWR0UH8EExw5fV1jTLNmqDrbmNuteOqQvBT aQvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776712139; x=1777316939; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=K53ny5L7FpS3N3CCZxy5e+UpFPXer/00U8PRdmewcwk=; b=TyVUTOxvQqUvZ3l6/0MxTJ/dB0XbXTJDng2m49ysmjok+EYl1Mu8ec+vyV1PTLvfPf awn12X+egmh2vQO/buonX/bXLpnIT0YapkXRJJc+2QUx+QkZlbVzvHN9rs/bzKQXXDQ6 DHqovdBmTbzi2PU9b/Tykhlztu4/gvfHnz7o9+XmD6+tMWkGQK4xohCixJjznIuKwHjD 1V+IgQ/4FrNIaKm9VPSdrpEYFkmLgCXgRedWeb9flWZx9KNIxAUEUm5hWs/1sATWMrqf Gm6WcN12MrYUMWbhJjB0Bvm6nTxYb4tjFS07JMjHnGcvlNo0S8iUYrRyi4wNbRC1l1Uk TinA== X-Forwarded-Encrypted: i=1; AFNElJ+XYIOToEscfRPihGlQSBxM96+F3h9QWChq6ee128QMtGJUAavPS5Dua4ZY7Itcckr6+Qb966HhP6xoWwS7@postgresql.org X-Gm-Message-State: AOJu0YwfWKV+Z23wgof0oMplcnXY+9RW1Fz5/8ZfecCfgE2rKLGdvyml +HhSIZeLn4eR4LO33dN6Jeiq/RdXTZIJ/SXHZyHg1YmISSDP8MD5Hiok+8cJsOPCht0BX/Jnu+B fAEFgMDOR7eLKr6+5mL8plrvv8Le165U= X-Gm-Gg: AeBDiespr9NbM64/gqO04+KeW0xwfOfUMsra7/4b/0IvmJKbx5v/zPDb9R8DLU1lOQa nXIGKm/R1IrxnnN1VVQ+gTEhra/0opaZACcVM0HjiqnWTSGu/Xwpj2AE6Oa/7kPIFGEhLwIT+XQ qbD01E/wvzyLdFCs+OzPFRz+x/eIK39GQXtYOcXCz01T7306KLNi2OiHOR0OdziUJXj/McQErkw 5RLyZ9RXQdSvf7VOne+cDRFFv42QWSCLccp2VQXQzwiRZ6juJsnqGH+DRJA9CJ38bmFB6pCfysE UssHWFdFJZ2C/U+SRWuIZmK6T+ywijumjlFg3GsOPztY34gKfBIoO7rN36l7tEAwc+YiAL0i69b FPaYfTix1UP0amSiO X-Received: by 2002:a4a:e685:0:b0:688:96d4:61e2 with SMTP id 006d021491bc7-694637d4edfmr5274581eaf.23.1776712138622; Mon, 20 Apr 2026 12:08:58 -0700 (PDT) MIME-Version: 1.0 References: <31d04a1b-c0cb-4e6f-a344-0db048a3b673@gmail.com> <414c3430-77a9-438e-9dc0-c66033f6be63@postgrespro.ru> In-Reply-To: From: Alexander Korotkov Date: Mon, 20 Apr 2026 22:08:46 +0300 X-Gm-Features: AQROBzD_IRJQO6kL83t6bXka3Dy_jYcol4O9mF8UbRVwdkHPr0UcmFSmXVcQoto Message-ID: Subject: Re: MERGE PARTITIONS and DEPENDS ON EXTENSION. To: Matheus Alcantara Cc: Dmitry Koval , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 16, 2026 at 9:03=E2=80=AFPM Matheus Alcantara wrote: > > On Tue Apr 14, 2026 at 6:05 AM -03, Dmitry Koval wrote: > > Hi Matheus! > > > > Thank you for patch. > > I agree that dependency should be automatically added for SPLIT > > PARTITION. But I'm not sure about MERGE PARTITION ... > > Might be it would be more correct to automatically add a dependency onl= y > > if all merged partitions have it? > > Hi, > > Thank you for taking a look on this! > > I agree with your suggestion. The attached patch implements the > intersection behavior for MERGE PARTITIONS: extension dependencies are > only preserved on the merged partition's index if all source partition > indexes have that dependency. > > For example: > MERGE(idx1(ext_a, ext_b), idx2(ext_a)) -> idx3(ext_a) -- only ext_a is c= ommon > MERGE(idx1(ext_a), idx2()) -> idx3() -- no common deps This is not obvious for me. I would rather trigger an error if there are different dependencies on merging partitions. > For SPLIT PARTITION, the behavior remains the same since there's only > one source partition, all its extension dependencies are copied to the > new partition indexes. > > While working on this patch, I noticed what might be a separate bug (or > perhaps intentional behavior that I don't understand): extension > dependencies on parent partitioned indexes don't seem to prevent DROP > EXTENSION, but dependencies on child partition indexes do. See this > example: > > CREATE EXTENSION IF NOT EXISTS btree_gist; > > CREATE TABLE t (i int) PARTITION BY RANGE (i); > CREATE TABLE t_1 PARTITION OF t FOR VALUES FROM (1) TO (2); > CREATE INDEX t_idx ON t USING gist (i); > > -- Add dependency on the PARENT partitioned index > ALTER INDEX t_idx DEPENDS ON EXTENSION btree_gist; > > -- This succeeds (I expected it to fail): > DROP EXTENSION btree_gist; > > But if I add the dependency on the child partition index instead: > > ALTER INDEX t_1_i_idx DEPENDS ON EXTENSION btree_gist; > > DROP EXTENSION btree_gist; > ERROR: cannot drop extension btree_gist because other objects depend on = it > DETAIL: index t_idx depends on operator class gist_int4_ops for access m= ethod gist > > Is this expected behavior, or a separate bug? I would have expected the > dependency on the parent index to also prevent the DROP. Note that if you don't create explicit dependency then you would get an error. When you create an explicit dependency index =3D> extension, it's a different kind than the automatic one. It causes index to be dropped on extension drop (as documented). Thus, if you create dependency child_index =3D> extension, then child_index gets dropped, but parent_index automatic dependency still prevents deletion. But if you create dependency parent_index =3D> extension then dropping of extension trigger dropping of the parent_index, in turn that dropping child_index. So, everything is dropped, no errors. I don't think there is a bug. ------ Regards, Alexander Korotkov Supabase