diff options
author | Magnus Hagander <magnus@hagander.net> | 2011-05-05 21:47:42 +0200 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2011-05-05 21:47:42 +0200 |
commit | d76a149c955a6525c8d42425c57e32d74d2c2eed (patch) | |
tree | 17a2229fde85cc780e6259d980443d4e38946274 | |
parent | fb3ad7895ece674fc5298df754253f70cda6a02e (diff) | |
download | postgresql-d76a149c955a6525c8d42425c57e32d74d2c2eed.tar.gz postgresql-d76a149c955a6525c8d42425c57e32d74d2c2eed.zip |
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.
-rw-r--r-- | src/backend/commands/indexcmds.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ff84045d4fc..b91e4a4bd2b 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -183,10 +183,22 @@ DefineIndex(RangeVar *heapRelation, /* Note: during bootstrap may see uncataloged relation */ if (rel->rd_rel->relkind != RELKIND_RELATION && rel->rd_rel->relkind != RELKIND_UNCATALOGED) - ereport(ERROR, - (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a table", - heapRelation->relname))); + { + if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE) + /* + * Custom error message for FOREIGN TABLE since the term is + * close to a regular table and can confuse the user. + */ + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot create index on foreign table \"%s\"", + heapRelation->relname))); + else + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("\"%s\" is not a table", + heapRelation->relname))); + } /* * Don't try to CREATE INDEX on temp tables of other backends. |