File tree 1 file changed +9
-10
lines changed
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -375,25 +375,24 @@ DefineIndex(Oid relationId,
375
375
relationId = RelationGetRelid (rel );
376
376
namespaceId = RelationGetNamespace (rel );
377
377
378
- if ( rel -> rd_rel -> relkind != RELKIND_RELATION &&
379
- rel -> rd_rel -> relkind != RELKIND_MATVIEW )
378
+ /* Ensure that it makes sense to index this kind of relation */
379
+ switch ( rel -> rd_rel -> relkind )
380
380
{
381
- if (rel -> rd_rel -> relkind == RELKIND_FOREIGN_TABLE )
382
-
383
- /*
384
- * Custom error message for FOREIGN TABLE since the term is close
385
- * to a regular table and can confuse the user.
386
- */
381
+ case RELKIND_RELATION :
382
+ case RELKIND_MATVIEW :
383
+ /* OK */
384
+ break ;
385
+ case RELKIND_FOREIGN_TABLE :
387
386
ereport (ERROR ,
388
387
(errcode (ERRCODE_WRONG_OBJECT_TYPE ),
389
388
errmsg ("cannot create index on foreign table \"%s\"" ,
390
389
RelationGetRelationName (rel ))));
391
- else if ( rel -> rd_rel -> relkind == RELKIND_PARTITIONED_TABLE )
390
+ case RELKIND_PARTITIONED_TABLE :
392
391
ereport (ERROR ,
393
392
(errcode (ERRCODE_WRONG_OBJECT_TYPE ),
394
393
errmsg ("cannot create index on partitioned table \"%s\"" ,
395
394
RelationGetRelationName (rel ))));
396
- else
395
+ default :
397
396
ereport (ERROR ,
398
397
(errcode (ERRCODE_WRONG_OBJECT_TYPE ),
399
398
errmsg ("\"%s\" is not a table or materialized view" ,
You can’t perform that action at this time.
0 commit comments