From: Nathan Bossart <nathandbossart@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Partitioned tables and [un]loggedness
Date: Wed, 18 Sep 2024 10:58:34 -0500
Message-ID: <Zur4qqhABOXtZS8h@nathan> (raw)
In-Reply-To: <ZurvG45F3lQHLw4G@nathan>
References: <Zs4-xnNDMEdiKQXo@nathan>
<ZtAY3ZkRVAIp3sxG@paquier.xyz>
<ZtCKiJZaoYBHBv05@nathan>
<ZtZW4gEJOPmeP-nT@paquier.xyz>
<ZtZn0-JVQuBUbpWw@nathan>
<Zta_CFeFCx7bMBL8@paquier.xyz>
<ZtcsLnUSuALqEyE-@nathan>
<Zt6cDnwSvnuLLnak@paquier.xyz>
<Zt-V90bS4diq4e0Q@paquier.xyz>
<ZurvG45F3lQHLw4G@nathan>
On Wed, Sep 18, 2024 at 10:17:47AM -0500, Nathan Bossart wrote:
> Could we also use ATT_PARTITIONED_TABLE to remove the partitioned table
> check in ATExecAddIndexConstraint()?
Eh, never mind. That ends up being gross because you have to redo the
relation type check in a few places.
--
nathan
Attachments:add_constraint_using_index_on_part_table.patch (text/plain, 2.6K) downloaddiff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.cindex 9966d1f53c..777de48c69 100644--- a/src/backend/commands/tablecmds.c+++ b/src/backend/commands/tablecmds.c@@ -4922,7 +4922,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
pass = AT_PASS_ADD_CONSTR;
break;
case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
- ATSimplePermissions(cmd->subtype, rel, ATT_TABLE | ATT_PARTITIONED_TABLE);+ ATSimplePermissions(cmd->subtype, rel, ATT_TABLE);
/* This command never recurses */
/* No command-specific prep needed */
pass = AT_PASS_ADD_INDEXCONSTR;
@@ -5583,6 +5583,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
pass = AT_PASS_ADD_INDEX;
break;
case AT_AddIndexConstraint:
+ ATSimplePermissions(cmd2->subtype, rel, ATT_TABLE);
/* This command never recurses */
/* No command-specific prep needed */
pass = AT_PASS_ADD_INDEXCONSTR;
@@ -5596,6 +5597,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
case CONSTR_PRIMARY:
case CONSTR_UNIQUE:
case CONSTR_EXCLUSION:
+ ATSimplePermissions(cmd2->subtype, rel, ATT_TABLE);
pass = AT_PASS_ADD_INDEXCONSTR;
break;
default:
@@ -9208,15 +9210,6 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
Assert(OidIsValid(index_oid));
Assert(stmt->isconstraint);
- /*- * Doing this on partitioned tables is not a simple feature to implement,- * so let's punt for now.- */- if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)- ereport(ERROR,- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),- errmsg("ALTER TABLE / ADD CONSTRAINT USING INDEX is not supported on partitioned tables")));-
indexRel = index_open(index_oid, AccessShareLock);
indexName = pstrdup(RelationGetRelationName(indexRel));
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.outindex cf6eac5734..bdb7731543 100644--- a/src/test/regress/expected/create_index.out+++ b/src/test/regress/expected/create_index.out@@ -1593,7 +1593,8 @@ DROP TABLE cwi_test;
CREATE TABLE cwi_test(a int) PARTITION BY hash (a);
create unique index on cwi_test (a);
alter table cwi_test add primary key using index cwi_test_a_idx ;
-ERROR: ALTER TABLE / ADD CONSTRAINT USING INDEX is not supported on partitioned tables+ERROR: ALTER action ADD CONSTRAINT cannot be performed on relation "cwi_test"+DETAIL: This operation is not supported for partitioned tables.
DROP TABLE cwi_test;
-- PRIMARY KEY constraint cannot be backed by a NULLS NOT DISTINCT index
CREATE TABLE cwi_test(a int, b int);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, michael@paquier.xyz, david.g.johnston@gmail.com
Subject: Re: Partitioned tables and [un]loggedness
In-Reply-To: <Zur4qqhABOXtZS8h@nathan>
References: <Zs4-xnNDMEdiKQXo@nathan> <ZtAY3ZkRVAIp3sxG@paquier.xyz> <ZtCKiJZaoYBHBv05@nathan> <ZtZW4gEJOPmeP-nT@paquier.xyz> <ZtZn0-JVQuBUbpWw@nathan> <Zta_CFeFCx7bMBL8@paquier.xyz> <ZtcsLnUSuALqEyE-@nathan> <Zt6cDnwSvnuLLnak@paquier.xyz> <Zt-V90bS4diq4e0Q@paquier.xyz> <ZurvG45F3lQHLw4G@nathan> <Zur4qqhABOXtZS8h@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox