Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d76a149

Browse files
committed
Clarify error message when attempting to create index on foreign table
Instead of just saying "is not a table", specifically state that indexes aren't supported on *foreign* tables.
1 parent fb3ad78 commit d76a149

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/backend/commands/indexcmds.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,22 @@ DefineIndex(RangeVar *heapRelation,
183183
/* Note: during bootstrap may see uncataloged relation */
184184
if (rel->rd_rel->relkind != RELKIND_RELATION &&
185185
rel->rd_rel->relkind != RELKIND_UNCATALOGED)
186-
ereport(ERROR,
187-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
188-
errmsg("\"%s\" is not a table",
189-
heapRelation->relname)));
186+
{
187+
if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
188+
/*
189+
* Custom error message for FOREIGN TABLE since the term is
190+
* close to a regular table and can confuse the user.
191+
*/
192+
ereport(ERROR,
193+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
194+
errmsg("cannot create index on foreign table \"%s\"",
195+
heapRelation->relname)));
196+
else
197+
ereport(ERROR,
198+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
199+
errmsg("\"%s\" is not a table",
200+
heapRelation->relname)));
201+
}
190202

191203
/*
192204
* Don't try to CREATE INDEX on temp tables of other backends.

0 commit comments

Comments
 (0)