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 1w0tMc-002Ial-1J for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 03:39:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0tMa-001bQg-1h for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 03:39: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 1w0tMZ-001bQY-3C for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 03:39:00 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0tMX-00000001sWT-2ljI for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 03:38:59 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-829abaaa92bso1135985b3a.1 for ; Thu, 12 Mar 2026 20:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773373136; x=1773977936; darn=lists.postgresql.org; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :from:to:cc:subject:date:message-id:reply-to; bh=u6Dz5SwhEZ2Shx+AYTiRgI5QNKBue3zQirzJVjgE2wU=; b=lgIXOjaRMBg1UbClOTymfpKSjhKo0fufu5zEKeKATqglTHWmUiSlkUCOWxykaB9n8m sSeT6upuhVPZ9eY1UOfgfbhicMA9H+13cgQk8uFbvtcjUaOqrMfOBO1ai9BMtNubmdZL rBjdPgwIdxp9dLsx4CbrwOITTVQ14DBrGkX7kZbl04SOJGPP/jAYiG9+Wxf8/zvd1JQb 5SMcUSNF590Fffb/09tgfjUwUgNYawYqe1uRZxIDxTVZ9DoaYf3bvFIl7t7nzE4XPr9z zI9qzxDUTuO4gCRWYvPR+fy/nw+o+ZyxpmPnZis9v89w25boTGGGNpjotemgOAD8mXwt 85iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773373136; x=1773977936; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u6Dz5SwhEZ2Shx+AYTiRgI5QNKBue3zQirzJVjgE2wU=; b=G2+YTRaPGtdnpd9U0MO2+sjz1LnPJ/7qx9Uh8fmUPxWOnEE7Ohahitd7Q+9diFRX3t zfNkUD4iGhoD+SKjxzFHYh6wlSeiFURU8g6eV8AXUrnft/XLBcbboIJe2dYcQs/kAN/P tsGvMkzfRwuMLWha15t4uKeVFmT5hJnZ2HpcD+mAwtHxMgGaHC9hSt0PsGrZ3Gwg6cy/ 1Rrv9RV7KhWRn2l6uvb7b8MY2+D5Xv8P25JBeRW//gbbLtZWv148Z0FEUOPP1DeTJrOd jTrLRQCTTsVSsLzhNs33//DoWw0PC6gjKYSKMHhNPgWlt/hJbDY5rnli9DuslIM0JMVQ xNPA== X-Gm-Message-State: AOJu0Ywgyq2dlwiJdMaXFTBrQLrFYKwy/R/iUGpcD0sk8GkQ5jQzJnOu VFSpsmgmhViBd0OEimWxKtowjNgb8JZ/29crBZ1TZiLW476OFov8ac3Rviw4qc5K X-Gm-Gg: ATEYQzwvtGQ9x+pL7ajo7m7gx++t+kgIXUsEflWYxLDixZtbcHzzdksWvCa7H6aU2Yk IjL0+YTGteoxnl/ThmBzqDaz1gDDSZX+V32dmpaEV/F5mfXhamdb2kUUVCrKOr0CvZvsjoh9+Id vY+PLiLuSRwdcUIex8cwHifPUWe210bHzGeXfxcjuXaAkPv88Bh6kP10WEq5V81Ku6bBn/kJeAq sHzpR+oEDKLOVjNnXVJvgL3bnYMirHqXnOUztVUP4Z/SkTioUHfcRoJD0Zf7MYgXtr9ZIHOMphY rPop5Uhmf86jDyVyduiLZ0awzgdxxP5cDc+FMbeZUE/UgkYjPI0HzsFAYDCgLk72KBmufsKM4bf N6UTC2ZpEGVdsAjNb3QS9uB70+JEWCj/lj9uwqAXGZDOwPsSeTJL2r80WWCFDdbY7LSwgywLGBh ZuiPVzhdQH0XYt/Z3m4Y14ZrTI7bhfEJpv02KBDikXnA== X-Received: by 2002:a05:6a00:451c:b0:829:b55e:1b27 with SMTP id d2e1a72fcca58-82a1991f9d4mr1359416b3a.53.1773373136197; Thu, 12 Mar 2026 20:38:56 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a07287ef8sm4956030b3a.29.2026.03.12.20.38.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Mar 2026 20:38:55 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_1FB7E407-F7EA-4173-B691-1D600391856E" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: tablecmds: reject CLUSTER ON for partitioned tables earlier Date: Fri, 13 Mar 2026 11:38:17 +0800 References: <07773235-2E94-478F-BEF6-38C73B0553B8@gmail.com> <16D5D52A-1B99-4371-982E-257C195D2924@gmail.com> <5244008D-79E1-484B-9407-21F5D388EC7F@gmail.com> <075DECA0-5214-4794-A265-5A979E1A49B7@gmail.com> To: Postgres hackers In-Reply-To: <075DECA0-5214-4794-A265-5A979E1A49B7@gmail.com> Message-Id: <8A3FAABD-F297-41D1-9B07-20A37E311C29@gmail.com> X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_1FB7E407-F7EA-4173-B691-1D600391856E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Jan 28, 2026, at 10:15, Chao Li wrote: >=20 >=20 >=20 >> On Jan 27, 2026, at 16:55, Zsolt Parragi = wrote: >>=20 >>> I added two new test cases in 0002 that trigger the check. >>=20 >> I also tested these scenarios previously. It's good that they are = part >> of the test suite, but they don't hit that error path. Verified with >> this: >>=20 >> diff --git a/src/backend/commands/tablecmds.c = b/src/backend/commands/tablecmds.c >> index 379f4d4ebaf..50f80724cb3 100644 >> --- a/src/backend/commands/tablecmds.c >> +++ b/src/backend/commands/tablecmds.c >> @@ -17857,9 +17857,7 @@ ATExecDropInherit(Relation rel, RangeVar >> *parent, LOCKMODE lockmode) >> Relation parent_rel; >>=20 >> if (rel->rd_rel->relispartition) >> - ereport(ERROR, >> - (errcode(ERRCODE_WRONG_OBJECT_TYPE), >> - errmsg("cannot change inheritance of a partition"))); >> + Assert(0); >>=20 >> /* >> * AccessShareLock on the parent is probably enough, seeing that DROP >=20 > Thank you so much for pointing out this, and sorry for = misunderstanding you. You are right, as the check has been added to = ATPrepChangeInherit(), the same check in ATExecDropInherit becomes = redundant. I thought you were talking about the check in = ATPrepChangeInherit(). >=20 > PFA v7: >=20 > * In 0001, replaced ereport with assert in mark_index_clustered(). See = my previous email for the analysis. > * In 0002, removed the redundant check of relispartition from = ATExecDropInherit(). >=20 > Best regards, > -- > Chao Li (Evan) > HighGo Software Co., Ltd. > https://www.highgo.com/ >=20 >=20 >=20 >=20 > = PFA v8: rebase requested by CF = https://commitfest.postgresql.org/patch/6415/ Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_1FB7E407-F7EA-4173-B691-1D600391856E Content-Disposition: attachment; filename=v8-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v8-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch" Content-Transfer-Encoding: quoted-printable =46rom=20ea40fc1bcfd317db87d970c67568f6a22a483337=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Wed,=2021=20Jan=202026=2011:27:03=20+0800=0ASubject:=20[PATCH=20= v8=201/2]=20tablecmds:=20reject=20CLUSTER=20ON=20for=20partitioned=20= tables=0A=20earlier=0A=0AALTER=20TABLE=20...=20CLUSTER=20ON=20and=20SET=20= WITHOUT=20CLUSTER=20are=20not=20supported=20for=0Apartitioned=20tables=20= and=20already=20fail=20today,=20but=20only=20at=20exec=20time.=0A=0A= Reject=20these=20commands=20earlier=20via=20ATSimplePermissions(),=20= matching=20the=0Ahandling=20of=20other=20unsupported=20ALTER=20TABLE=20= actions=20on=20partitioned=20tables=0A(such=20as=20SET=20LOGGED=20/=20= SET=20UNLOGGED).=20This=20centralizes=20the=20relation-kind=0Acheck=20in=20= the=20ALTER=20TABLE=20preparation=20phase,=20improving=20consistency=20= and=0Amaintainability.=0A=0AAs=20a=20result,=20partitioned=20tables=20= now=20report=20the=20standard=20ATSimplePermissions()=0Aerror=20for=20= unsupported=20ALTER=20TABLE=20actions.=0A=0AAlso,=20replace=20= ereport(ERROR)=20with=20an=20Assert()=20in=20mark_index_clustered(),=0A= because=20after=20this=20change=20no=20code=20path=20should=20call=20it=20= for=20a=20partitioned=20table.=0A=0AAuthor:=20Chao=20Li=20= =0AReviewed-by:=20Zsolt=20Parragi=20= =0ADiscussion:=20= https://postgr.es/m/CAEoWx2kggo1N2kDH6OSfXHL_5gKg3DqQ0PdNuL4LH4XSTKJ3-g@ma= il.gmail.com=0A---=0A=20src/backend/commands/cluster.c=20=20=20=20=20=20=20= =20|=207=20++-----=0A=20src/backend/commands/tablecmds.c=20=20=20=20=20=20= |=202=20+-=0A=20src/test/regress/expected/cluster.out=20|=206=20++++--=0A= =203=20files=20changed,=207=20insertions(+),=208=20deletions(-)=0A=0A= diff=20--git=20a/src/backend/commands/cluster.c=20= b/src/backend/commands/cluster.c=0Aindex=203bfaa663699..2ef9c08fa03=20= 100644=0A---=20a/src/backend/commands/cluster.c=0A+++=20= b/src/backend/commands/cluster.c=0A@@=20-572,11=20+572,8=20@@=20= mark_index_clustered(Relation=20rel,=20Oid=20indexOid,=20bool=20= is_internal)=0A=20=09Relation=09pg_index;=0A=20=09ListCell=20=20=20= *index;=0A=20=0A-=09/*=20Disallow=20applying=20to=20a=20partitioned=20= table=20*/=0A-=09if=20(rel->rd_rel->relkind=20=3D=3D=20= RELKIND_PARTITIONED_TABLE)=0A-=09=09ereport(ERROR,=0A-=09=09=09=09= (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),=0A-=09=09=09=09=20= errmsg("cannot=20mark=20index=20clustered=20in=20partitioned=20= table")));=0A+=09/*=20This=20function=20is=20only=20valid=20for=20= non-partitioned=20tables=20*/=0A+=09Assert(rel->rd_rel->relkind=20!=3D=20= RELKIND_PARTITIONED_TABLE);=0A=20=0A=20=09/*=0A=20=09=20*=20If=20the=20= index=20is=20already=20marked=20clustered,=20no=20need=20to=20do=20= anything.=0Adiff=20--git=20a/src/backend/commands/tablecmds.c=20= b/src/backend/commands/tablecmds.c=0Aindex=20cd6d720386f..7d677feb1ea=20= 100644=0A---=20a/src/backend/commands/tablecmds.c=0A+++=20= b/src/backend/commands/tablecmds.c=0A@@=20-5160,7=20+5160,7=20@@=20= ATPrepCmd(List=20**wqueue,=20Relation=20rel,=20AlterTableCmd=20*cmd,=0A=20= =09=09case=20AT_ClusterOn:=09=09/*=20CLUSTER=20ON=20*/=0A=20=09=09case=20= AT_DropCluster:=09/*=20SET=20WITHOUT=20CLUSTER=20*/=0A=20=09=09=09= ATSimplePermissions(cmd->subtype,=20rel,=0A-=09=09=09=09=09=09=09=09= ATT_TABLE=20|=20ATT_PARTITIONED_TABLE=20|=20ATT_MATVIEW);=0A+=09=09=09=09= =09=09=09=09ATT_TABLE=20|=20ATT_MATVIEW);=0A=20=09=09=09/*=20These=20= commands=20never=20recurse=20*/=0A=20=09=09=09/*=20No=20command-specific=20= prep=20needed=20*/=0A=20=09=09=09pass=20=3D=20AT_PASS_MISC;=0Adiff=20= --git=20a/src/test/regress/expected/cluster.out=20= b/src/test/regress/expected/cluster.out=0Aindex=20= 24b0b1a8fce..269f163efa6=20100644=0A---=20= a/src/test/regress/expected/cluster.out=0A+++=20= b/src/test/regress/expected/cluster.out=0A@@=20-492,9=20+492,11=20@@=20= Number=20of=20partitions:=203=20(Use=20\d+=20to=20list=20them.)=0A=20= CLUSTER=20clstrpart;=0A=20ERROR:=20=20there=20is=20no=20previously=20= clustered=20index=20for=20table=20"clstrpart"=0A=20ALTER=20TABLE=20= clstrpart=20SET=20WITHOUT=20CLUSTER;=0A-ERROR:=20=20cannot=20mark=20= index=20clustered=20in=20partitioned=20table=0A+ERROR:=20=20ALTER=20= action=20SET=20WITHOUT=20CLUSTER=20cannot=20be=20performed=20on=20= relation=20"clstrpart"=0A+DETAIL:=20=20This=20operation=20is=20not=20= supported=20for=20partitioned=20tables.=0A=20ALTER=20TABLE=20clstrpart=20= CLUSTER=20ON=20clstrpart_idx;=0A-ERROR:=20=20cannot=20mark=20index=20= clustered=20in=20partitioned=20table=0A+ERROR:=20=20ALTER=20action=20= CLUSTER=20ON=20cannot=20be=20performed=20on=20relation=20"clstrpart"=0A= +DETAIL:=20=20This=20operation=20is=20not=20supported=20for=20= partitioned=20tables.=0A=20--=20and=20they=20cannot=20get=20an=20= index-ordered=20REPACK=20without=20an=20explicit=20index=20name=0A=20= REPACK=20clstrpart=20USING=20INDEX;=0A=20ERROR:=20=20cannot=20execute=20= REPACK=20on=20partitioned=20table=20"clstrpart"=20USING=20INDEX=20with=20= no=20index=20name=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_1FB7E407-F7EA-4173-B691-1D600391856E Content-Disposition: attachment; filename=v8-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v8-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch" Content-Transfer-Encoding: quoted-printable =46rom=203f77f1b0e1e189ede9bafbb18cd20aeb385b0050=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Thu,=2022=20Jan=202026=2016:47:58=20+0800=0ASubject:=20[PATCH=20= v8=202/2]=20tablecmds:=20reject=20INHERIT=20/=20NO=20INHERIT=20for=20= partitioned=0A=20tables=20earlier=0A=0AALTER=20TABLE=20...=20INHERIT=20= and=20NO=20INHERIT=20are=20not=20supported=20for=20partitioned=0Atables=20= and=20already=20fail=20today,=20but=20only=20via=20ad-hoc=20checks=20in=20= command-=0Aspecific=20preparation=20code=20or=20later=20at=20execution=20= time.=0A=0AReject=20these=20commands=20earlier=20via=20= ATSimplePermissions(),=20matching=20the=0Ahandling=20of=20other=20= unsupported=20ALTER=20TABLE=20actions=20on=20partitioned=20tables.=0A= This=20centralizes=20relation-kind=20checks=20in=20the=20common=20= permission=20framework=0Aand=20produces=20the=20standard,=20consistent=20= error=20message.=0A=0AWhile=20doing=20this,=20fix=20two=20related=20= issues=20in=20the=20preparation=20logic:=0A-=20The=20header=20comment=20= of=20ATPrepAddInherit=20was=20a=20stale=20copy-paste=20that=0A=20=20= described=20behavior=20no=20longer=20implemented=20there.=0A-=20NO=20= INHERIT=20previously=20didn't=20use=20ATPrepAddInherit,=20causing=20it=20= to=20reach=0A=20=20execution-time=20checks=20unnecessarily.=20= Consolidate=20preparation=20into=20a=0A=20=20shared=20helper=20used=20by=20= both=20INHERIT=20and=20NO=20INHERIT,=20ensuring=20both=20are=0A=20=20= rejected=20uniformly=20and=20as=20early=20as=20possible.=0A=0AAuthor:=20= Chao=20Li=20=0AReviewed-by:=20Zsolt=20Parragi=20= =0ADiscussion:=20= https://postgr.es/m/CAEoWx2kggo1N2kDH6OSfXHL_5gKg3DqQ0PdNuL4LH4XSTKJ3-g@ma= il.gmail.com=0A---=0A=20src/backend/commands/tablecmds.c=20=20=20=20=20=20= =20=20=20=20|=2036=20++++++++++-------------=0A=20= src/test/regress/expected/alter_table.out=20|=2015=20++++++++--=0A=20= src/test/regress/sql/alter_table.sql=20=20=20=20=20=20|=20=208=20+++--=0A= =203=20files=20changed,=2034=20insertions(+),=2025=20deletions(-)=0A=0A= diff=20--git=20a/src/backend/commands/tablecmds.c=20= b/src/backend/commands/tablecmds.c=0Aindex=207d677feb1ea..629cf795bf4=20= 100644=0A---=20a/src/backend/commands/tablecmds.c=0A+++=20= b/src/backend/commands/tablecmds.c=0A@@=20-694,7=20+694,7=20@@=20static=20= void=20ATExecEnableDisableTrigger(Relation=20rel,=20const=20char=20= *trigname,=0A=20=09=09=09=09=09=09=09=09=09=20=20=20LOCKMODE=20= lockmode);=0A=20static=20void=20ATExecEnableDisableRule(Relation=20rel,=20= const=20char=20*rulename,=0A=20=09=09=09=09=09=09=09=09=09char=20= fires_when,=20LOCKMODE=20lockmode);=0A-static=20void=20= ATPrepAddInherit(Relation=20child_rel);=0A+static=20void=20= ATPrepChangeInherit(Relation=20child_rel);=0A=20static=20ObjectAddress=20= ATExecAddInherit(Relation=20child_rel,=20RangeVar=20*parent,=20LOCKMODE=20= lockmode);=0A=20static=20ObjectAddress=20ATExecDropInherit(Relation=20= rel,=20RangeVar=20*parent,=20LOCKMODE=20lockmode);=0A=20static=20void=20= drop_parent_dependency(Oid=20relid,=20Oid=20refclassid,=20Oid=20= refobjid,=0A@@=20-5212,16=20+5212,16=20@@=20ATPrepCmd(List=20**wqueue,=20= Relation=20rel,=20AlterTableCmd=20*cmd,=0A=20=09=09=09break;=0A=20=09=09= case=20AT_AddInherit:=09=09/*=20INHERIT=20*/=0A=20=09=09=09= ATSimplePermissions(cmd->subtype,=20rel,=0A-=09=09=09=09=09=09=09=09= ATT_TABLE=20|=20ATT_PARTITIONED_TABLE=20|=20ATT_FOREIGN_TABLE);=0A+=09=09= =09=09=09=09=09=09ATT_TABLE=20|=20ATT_FOREIGN_TABLE);=0A=20=09=09=09/*=20= This=20command=20never=20recurses=20*/=0A-=09=09=09= ATPrepAddInherit(rel);=0A+=09=09=09ATPrepChangeInherit(rel);=0A=20=09=09=09= pass=20=3D=20AT_PASS_MISC;=0A=20=09=09=09break;=0A=20=09=09case=20= AT_DropInherit:=09/*=20NO=20INHERIT=20*/=0A=20=09=09=09= ATSimplePermissions(cmd->subtype,=20rel,=0A-=09=09=09=09=09=09=09=09= ATT_TABLE=20|=20ATT_PARTITIONED_TABLE=20|=20ATT_FOREIGN_TABLE);=0A+=09=09= =09=09=09=09=09=09ATT_TABLE=20|=20ATT_FOREIGN_TABLE);=0A=20=09=09=09/*=20= This=20command=20never=20recurses=20*/=0A-=09=09=09/*=20No=20= command-specific=20prep=20needed=20*/=0A+=09=09=09= ATPrepChangeInherit(rel);=0A=20=09=09=09pass=20=3D=20AT_PASS_MISC;=0A=20=09= =09=09break;=0A=20=09=09case=20AT_AlterConstraint:=09/*=20ALTER=20= CONSTRAINT=20*/=0A@@=20-17456,14=20+17456,14=20@@=20= ATExecEnableDisableRule(Relation=20rel,=20const=20char=20*rulename,=0A=20= }=0A=20=0A=20/*=0A-=20*=20ALTER=20TABLE=20INHERIT=0A+=20*=20Prepare=20to=20= change=20inheritance.=0A=20=20*=0A-=20*=20Add=20a=20parent=20to=20the=20= child's=20parents.=20This=20verifies=20that=20all=20the=20columns=20and=0A= -=20*=20check=20constraints=20of=20the=20parent=20appear=20in=20the=20= child=20and=20that=20they=20have=20the=0A-=20*=20same=20data=20types=20= and=20expressions.=0A+=20*=20A=20child=20table=20cannot=20be=20a=20typed=20= table=20or=20a=20partition.=20We=20don't=20need=20to=20check=0A+=20*=20= partitioned=20table=20here,=20because=20it=20has=20been=20blocked=20by=20= ATSimplePermissions=20in=0A+=20*=20ATPrepCmd.=0A=20=20*/=0A=20static=20= void=0A-ATPrepAddInherit(Relation=20child_rel)=0A= +ATPrepChangeInherit(Relation=20child_rel)=0A=20{=0A=20=09if=20= (child_rel->rd_rel->reloftype)=0A=20=09=09ereport(ERROR,=0A@@=20= -17474,14=20+17474,15=20@@=20ATPrepAddInherit(Relation=20child_rel)=0A=20= =09=09ereport(ERROR,=0A=20=09=09=09=09= (errcode(ERRCODE_WRONG_OBJECT_TYPE),=0A=20=09=09=09=09=20errmsg("cannot=20= change=20inheritance=20of=20a=20partition")));=0A-=0A-=09if=20= (child_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE)=0A-=09=09= ereport(ERROR,=0A-=09=09=09=09(errcode(ERRCODE_WRONG_OBJECT_TYPE),=0A-=09= =09=09=09=20errmsg("cannot=20change=20inheritance=20of=20partitioned=20= table")));=0A=20}=0A=20=0A=20/*=0A+=20*=20ALTER=20TABLE=20INHERIT=0A+=20= *=0A+=20*=20Add=20a=20parent=20to=20the=20child's=20parents.=20This=20= verifies=20that=20all=20the=20columns=20and=0A+=20*=20check=20= constraints=20of=20the=20parent=20appear=20in=20the=20child=20and=20that=20= they=20have=20the=0A+=20*=20same=20data=20types=20and=20expressions.=0A+=20= *=0A=20=20*=20Return=20the=20address=20of=20the=20new=20parent=20= relation.=0A=20=20*/=0A=20static=20ObjectAddress=0A@@=20-18052,11=20= +18053,6=20@@=20ATExecDropInherit(Relation=20rel,=20RangeVar=20*parent,=20= LOCKMODE=20lockmode)=0A=20=09ObjectAddress=20address;=0A=20=09Relation=09= parent_rel;=0A=20=0A-=09if=20(rel->rd_rel->relispartition)=0A-=09=09= ereport(ERROR,=0A-=09=09=09=09(errcode(ERRCODE_WRONG_OBJECT_TYPE),=0A-=09= =09=09=09=20errmsg("cannot=20change=20inheritance=20of=20a=20= partition")));=0A-=0A=20=09/*=0A=20=09=20*=20AccessShareLock=20on=20the=20= parent=20is=20probably=20enough,=20seeing=20that=20DROP=0A=20=09=20*=20= TABLE=20doesn't=20lock=20parent=20tables=20at=20all.=20=20We=20need=20= some=20lock=20since=20we'll=0Adiff=20--git=20= a/src/test/regress/expected/alter_table.out=20= b/src/test/regress/expected/alter_table.out=0Aindex=20= 5998c670aa3..ccd79dfecc0=20100644=0A---=20= a/src/test/regress/expected/alter_table.out=0A+++=20= b/src/test/regress/expected/alter_table.out=0A@@=20-4007,10=20+4007,19=20= @@=20CREATE=20TABLE=20nonpartitioned=20(=0A=20=09a=20int,=0A=20=09b=20= int=0A=20);=0A-ALTER=20TABLE=20partitioned=20INHERIT=20nonpartitioned;=0A= -ERROR:=20=20cannot=20change=20inheritance=20of=20partitioned=20table=0A= -ALTER=20TABLE=20nonpartitioned=20INHERIT=20partitioned;=0A+ALTER=20= TABLE=20partitioned=20INHERIT=20nonpartitioned;=20--=20fail=0A+ERROR:=20=20= ALTER=20action=20INHERIT=20cannot=20be=20performed=20on=20relation=20= "partitioned"=0A+DETAIL:=20=20This=20operation=20is=20not=20supported=20= for=20partitioned=20tables.=0A+ALTER=20TABLE=20partitioned=20NO=20= INHERIT=20nonpartitioned;=20--=20fail=0A+ERROR:=20=20ALTER=20action=20NO=20= INHERIT=20cannot=20be=20performed=20on=20relation=20"partitioned"=0A= +DETAIL:=20=20This=20operation=20is=20not=20supported=20for=20= partitioned=20tables.=0A+ALTER=20TABLE=20nonpartitioned=20INHERIT=20= partitioned;=20--=20fail=0A=20ERROR:=20=20cannot=20inherit=20from=20= partitioned=20table=20"partitioned"=0A+CREATE=20TABLE=20partitioned_p1=20= PARTITION=20OF=20partitioned=20FOR=20VALUES=20FROM=20(0,=200)=20TO=20= (10,=20100);=0A+ALTER=20TABLE=20partitioned_p1=20INHERIT=20= nonpartitioned;=20--=20fail=0A+ERROR:=20=20cannot=20change=20inheritance=20= of=20a=20partition=0A+ALTER=20TABLE=20partitioned_p1=20NO=20INHERIT=20= nonpartitioned;=20--=20fail=0A+ERROR:=20=20cannot=20change=20inheritance=20= of=20a=20partition=0A=20--=20cannot=20add=20NO=20INHERIT=20constraint=20= to=20partitioned=20tables=0A=20ALTER=20TABLE=20partitioned=20ADD=20= CONSTRAINT=20chk_a=20CHECK=20(a=20>=200)=20NO=20INHERIT;=0A=20ERROR:=20=20= cannot=20add=20NO=20INHERIT=20constraint=20to=20partitioned=20table=20= "partitioned"=0Adiff=20--git=20a/src/test/regress/sql/alter_table.sql=20= b/src/test/regress/sql/alter_table.sql=0Aindex=20= d6b6381ae5c..f5f13bbd3e7=20100644=0A---=20= a/src/test/regress/sql/alter_table.sql=0A+++=20= b/src/test/regress/sql/alter_table.sql=0A@@=20-2405,8=20+2405,12=20@@=20= CREATE=20TABLE=20nonpartitioned=20(=0A=20=09a=20int,=0A=20=09b=20int=0A=20= );=0A-ALTER=20TABLE=20partitioned=20INHERIT=20nonpartitioned;=0A-ALTER=20= TABLE=20nonpartitioned=20INHERIT=20partitioned;=0A+ALTER=20TABLE=20= partitioned=20INHERIT=20nonpartitioned;=20--=20fail=0A+ALTER=20TABLE=20= partitioned=20NO=20INHERIT=20nonpartitioned;=20--=20fail=0A+ALTER=20= TABLE=20nonpartitioned=20INHERIT=20partitioned;=20--=20fail=0A+CREATE=20= TABLE=20partitioned_p1=20PARTITION=20OF=20partitioned=20FOR=20VALUES=20= FROM=20(0,=200)=20TO=20(10,=20100);=0A+ALTER=20TABLE=20partitioned_p1=20= INHERIT=20nonpartitioned;=20--=20fail=0A+ALTER=20TABLE=20partitioned_p1=20= NO=20INHERIT=20nonpartitioned;=20--=20fail=0A=20=0A=20--=20cannot=20add=20= NO=20INHERIT=20constraint=20to=20partitioned=20tables=0A=20ALTER=20TABLE=20= partitioned=20ADD=20CONSTRAINT=20chk_a=20CHECK=20(a=20>=200)=20NO=20= INHERIT;=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_1FB7E407-F7EA-4173-B691-1D600391856E--