Re: ERROR: "ft1" is of the wrong type. - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: ERROR: "ft1" is of the wrong type.
Date
Msg-id 20210709.104413.1800713570585460422.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: ERROR: "ft1" is of the wrong type.  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
List pgsql-hackers
At Thu, 8 Jul 2021 10:02:53 +0200, Peter Eisentraut <peter.eisentraut@enterprisedb.com> wrote in 
> My patch is now committed.  The issue that started this thread now behaves
> like this:
> 
> ALTER TABLE ft1 ATTACH PARTITION ...;
> ERROR:  ALTER action ATTACH PARTITION cannot be performed on relation "ft1"
> DETAIL:  This operation is not supported for foreign tables.
> 
> So, for PG15, this is taken care of.

Cool.

> Backpatches under the old style for missing combinations would still be in
> scope, but there my comment on the proposed patches is that I would rather not
> remove apparently unused combinations from back branches.

Sounds reasonable. So the attached are that for PG11-PG14.  11 and 12
shares the same patch.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
From f04c1968c0305142ab81e80a193352e1037ec4ef Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Date: Thu, 8 Jul 2021 17:55:25 +0900
Subject: [PATCH v2] Add missing targets in ATWrongRelkindError

ATWrongRelkindError yields an ambiguous message ""tbl" is of the wrong
type" due the lack of some combinations of allowed_targets. Add the
missing items. We don't remove apparently unused entries in case
someone is using them.
---
 src/backend/commands/tablecmds.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 97a9725df7..3432f9bdd3 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6029,6 +6029,12 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
         case ATT_TABLE | ATT_MATVIEW | ATT_INDEX:
             msg = _("\"%s\" is not a table, materialized view, or index");
             break;
+        case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX:
+            msg = _("\"%s\" is not a table, materialized view, index, or partitioned index");
+            break;
+        case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX | ATT_FOREIGN_TABLE:
+            msg = _("\"%s\" is not a table, materialized view, index, partitioned index, or foreign table");
+            break;
         case ATT_TABLE | ATT_MATVIEW | ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a table, materialized view, or foreign table");
             break;
@@ -6041,9 +6047,15 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
         case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a table, materialized view, index, or foreign table");
             break;
+        case ATT_TABLE | ATT_PARTITIONED_INDEX:
+            msg = _("\"%s\" is not a table or partitioned index");
+            break;
         case ATT_VIEW:
             msg = _("\"%s\" is not a view");
             break;
+        case ATT_INDEX:
+            msg = _("\"%s\" is not an index");
+            break;
         case ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a foreign table");
             break;
-- 
2.27.0

From b1fc39633ba1053a4933f89e70369a0cef966840 Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Date: Thu, 8 Jul 2021 18:01:19 +0900
Subject: [PATCH v2] Add missing targets in ATWrongRelkindError

ATWrongRelkindError yields an ambiguous message ""tbl" is of the wrong
type" due the lack of some combinations of allowed_targets. Add the
missing items. We don't remove apparently unused entries in case
someone is using them.
---
 src/backend/commands/tablecmds.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 135fa46981..1bf4ca6884 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -5649,6 +5649,12 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
         case ATT_TABLE | ATT_MATVIEW | ATT_INDEX:
             msg = _("\"%s\" is not a table, materialized view, or index");
             break;
+        case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX:
+            msg = _("\"%s\" is not a table, materialized view, index, or partitioned index");
+            break;
+        case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX | ATT_FOREIGN_TABLE:
+            msg = _("\"%s\" is not a table, materialized view, index, partitioned index, or foreign table");
+            break;
         case ATT_TABLE | ATT_MATVIEW | ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a table, materialized view, or foreign table");
             break;
@@ -5661,6 +5667,9 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
         case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a table, materialized view, index, or foreign table");
             break;
+        case ATT_TABLE | ATT_PARTITIONED_INDEX:
+            msg = _("\"%s\" is not a table or partitioned index");
+            break;
         case ATT_VIEW:
             msg = _("\"%s\" is not a view");
             break;
-- 
2.27.0

From 71f6da9183e6d41d2f787f6a591772956a2b53df Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Date: Thu, 8 Jul 2021 18:03:17 +0900
Subject: [PATCH v2] Add missing targets in ATWrongRelkindError

ATWrongRelkindError yields an ambiguous message ""tbl" is of the wrong
type" due the lack of some combinations of allowed_targets. Add the
missing items. We don't remove apparently unused entries in case
someone is using them.
---
 src/backend/commands/tablecmds.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 816ce8521f..8dc43195a5 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -5372,6 +5372,9 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
         case ATT_TABLE | ATT_MATVIEW | ATT_INDEX:
             msg = _("\"%s\" is not a table, materialized view, or index");
             break;
+        case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX:
+            msg = _("\"%s\" is not a table, materialized view, index, or partitioned index");
+            break;
         case ATT_TABLE | ATT_MATVIEW | ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a table, materialized view, or foreign table");
             break;
@@ -5384,6 +5387,9 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
         case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_FOREIGN_TABLE:
             msg = _("\"%s\" is not a table, materialized view, index, or foreign table");
             break;
+        case ATT_TABLE | ATT_PARTITIONED_INDEX:
+            msg = _("\"%s\" is not a table or partitioned index");
+            break;
         case ATT_VIEW:
             msg = _("\"%s\" is not a view");
             break;
-- 
2.27.0


pgsql-hackers by date:

Previous
From: Quan Zongliang
Date:
Subject: Re: bugfix: when the blocksize is 32k, the function page_header of pageinspect returns negative numbers.
Next
From: Andres Freund
Date:
Subject: Re: Overflow hazard in pgbench