mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Fix maintenance hazards caused by ill-considered use of default: cases.
Remove default cases from assorted switches over ObjectClass and some related enum types, so that we'll get compiler warnings when someone adds a new enum value without accounting for it in all these places. In passing, re-order some switch cases as needed to match the declaration of enum ObjectClass. OK, that's just neatnik-ism, but I dislike code that looks like it was assembled with the help of a dartboard. Discussion: https://postgr.es/m/20170512221010.nglatgt5azzdxjlj@alvherre.pgsql
This commit is contained in:
@ -543,7 +543,8 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
|
||||
* so it only needs to cover object types that can be members of an
|
||||
* extension, and it doesn't have to deal with certain special cases
|
||||
* such as not wanting to process array types --- those should never
|
||||
* be direct members of an extension anyway.
|
||||
* be direct members of an extension anyway. Nonetheless, we insist
|
||||
* on listing all OCLASS types in the switch.
|
||||
*
|
||||
* Returns the OID of the object's previous namespace, or InvalidOid if
|
||||
* object doesn't have a schema.
|
||||
@ -578,12 +579,13 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
|
||||
oldNspOid = AlterTypeNamespace_oid(objid, nspOid, objsMoved);
|
||||
break;
|
||||
|
||||
case OCLASS_PROC:
|
||||
case OCLASS_COLLATION:
|
||||
case OCLASS_CONVERSION:
|
||||
case OCLASS_OPERATOR:
|
||||
case OCLASS_OPCLASS:
|
||||
case OCLASS_OPFAMILY:
|
||||
case OCLASS_PROC:
|
||||
case OCLASS_STATISTIC_EXT:
|
||||
case OCLASS_TSPARSER:
|
||||
case OCLASS_TSDICT:
|
||||
case OCLASS_TSTEMPLATE:
|
||||
@ -600,8 +602,38 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case OCLASS_CAST:
|
||||
case OCLASS_CONSTRAINT:
|
||||
case OCLASS_DEFAULT:
|
||||
case OCLASS_LANGUAGE:
|
||||
case OCLASS_LARGEOBJECT:
|
||||
case OCLASS_AM:
|
||||
case OCLASS_AMOP:
|
||||
case OCLASS_AMPROC:
|
||||
case OCLASS_REWRITE:
|
||||
case OCLASS_TRIGGER:
|
||||
case OCLASS_SCHEMA:
|
||||
case OCLASS_ROLE:
|
||||
case OCLASS_DATABASE:
|
||||
case OCLASS_TBLSPACE:
|
||||
case OCLASS_FDW:
|
||||
case OCLASS_FOREIGN_SERVER:
|
||||
case OCLASS_USER_MAPPING:
|
||||
case OCLASS_DEFACL:
|
||||
case OCLASS_EXTENSION:
|
||||
case OCLASS_EVENT_TRIGGER:
|
||||
case OCLASS_POLICY:
|
||||
case OCLASS_PUBLICATION:
|
||||
case OCLASS_PUBLICATION_REL:
|
||||
case OCLASS_SUBSCRIPTION:
|
||||
case OCLASS_TRANSFORM:
|
||||
/* ignore object types that don't have schema-qualified names */
|
||||
break;
|
||||
|
||||
/*
|
||||
* There's intentionally no default: case here; we want the
|
||||
* compiler to warn if a new OCLASS hasn't been handled above.
|
||||
*/
|
||||
}
|
||||
|
||||
return oldNspOid;
|
||||
|
Reference in New Issue
Block a user