File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -375,25 +375,24 @@ DefineIndex(Oid relationId,
375375 relationId = RelationGetRelid (rel );
376376 namespaceId = RelationGetNamespace (rel );
377377
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 )
380380 {
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 :
387386 ereport (ERROR ,
388387 (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
389388 errmsg ("cannot create index on foreign table \"%s\"" ,
390389 RelationGetRelationName (rel ))));
391- else if ( rel -> rd_rel -> relkind == RELKIND_PARTITIONED_TABLE )
390+ case RELKIND_PARTITIONED_TABLE :
392391 ereport (ERROR ,
393392 (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
394393 errmsg ("cannot create index on partitioned table \"%s\"" ,
395394 RelationGetRelationName (rel ))));
396- else
395+ default :
397396 ereport (ERROR ,
398397 (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
399398 errmsg ("\"%s\" is not a table or materialized view" ,
You can’t perform that action at this time.
0 commit comments