1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-06 19:59:18 +03:00

Clean up warnings from -Wimplicit-fallthrough.

Recent gcc can warn about switch-case fall throughs that are not
explicitly labeled as intentional.  This seems like a good thing,
so clean up the warnings exposed thereby by labeling all such
cases with comments that gcc will recognize.

In files that already had one or more suitable comments, I generally
matched the existing style of those.  Otherwise I went with
/* FALLTHROUGH */, which is one of the spellings approved at the
more-restrictive-than-default level -Wimplicit-fallthrough=4.
(At the default level you can also spell it /* FALL ?THRU */,
and it's not picky about case.  What you can't do is include
additional text in the same comment, so some existing comments
containing versions of this aren't good enough.)

Testing with gcc 8.0.1 (Fedora 28's current version), I found that
I also had to put explicit "break"s after elog(ERROR) or ereport(ERROR);
apparently, for this purpose gcc doesn't recognize that those don't
return.  That seems like possibly a gcc bug, but it's fine because
in most places we did that anyway; so this amounts to a visit from the
style police.

Discussion: https://postgr.es/m/15083.1525207729@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2018-05-01 19:35:08 -04:00
parent 1667148a4d
commit 41c912cad1
28 changed files with 128 additions and 25 deletions

View File

@ -88,6 +88,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
case BTGreaterEqualStrategyNumber: case BTGreaterEqualStrategyNumber:
case BTGreaterStrategyNumber: case BTGreaterStrategyNumber:
*ptr_partialmatch = true; *ptr_partialmatch = true;
/* FALLTHROUGH */
case BTEqualStrategyNumber: case BTEqualStrategyNumber:
entries[0] = datum; entries[0] = datum;
break; break;

View File

@ -97,18 +97,22 @@ verify_hash_page(bytea *raw_page, int flags)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("page is not a hash meta page"))); errmsg("page is not a hash meta page")));
break;
case LH_BUCKET_PAGE | LH_OVERFLOW_PAGE: case LH_BUCKET_PAGE | LH_OVERFLOW_PAGE:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("page is not a hash bucket or overflow page"))); errmsg("page is not a hash bucket or overflow page")));
break;
case LH_OVERFLOW_PAGE: case LH_OVERFLOW_PAGE:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("page is not a hash overflow page"))); errmsg("page is not a hash overflow page")));
break;
default: default:
elog(ERROR, elog(ERROR,
"hash page of type %08x not in mask %08x", "hash page of type %08x not in mask %08x",
pagetype, flags); pagetype, flags);
break;
} }
} }

View File

@ -466,9 +466,9 @@ hash_any(register const unsigned char *k, register int keylen)
/* fall through */ /* fall through */
case 9: case 9:
c += ((uint32) k[8] << 24); c += ((uint32) k[8] << 24);
/* the lowest byte of c is reserved for the length */
/* fall through */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1]; b += ka[1];
a += ka[0]; a += ka[0];
break; break;
@ -505,9 +505,9 @@ hash_any(register const unsigned char *k, register int keylen)
/* fall through */ /* fall through */
case 9: case 9:
c += ((uint32) k[8] << 8); c += ((uint32) k[8] << 8);
/* the lowest byte of c is reserved for the length */
/* fall through */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1]; b += ka[1];
a += ka[0]; a += ka[0];
break; break;
@ -558,57 +558,77 @@ hash_any(register const unsigned char *k, register int keylen)
/* handle the last 11 bytes */ /* handle the last 11 bytes */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
switch (len) /* all the case statements fall through */ switch (len)
{ {
case 11: case 11:
c += ((uint32) k[10] << 8); c += ((uint32) k[10] << 8);
/* fall through */
case 10: case 10:
c += ((uint32) k[9] << 16); c += ((uint32) k[9] << 16);
/* fall through */
case 9: case 9:
c += ((uint32) k[8] << 24); c += ((uint32) k[8] << 24);
/* the lowest byte of c is reserved for the length */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += k[7]; b += k[7];
/* fall through */
case 7: case 7:
b += ((uint32) k[6] << 8); b += ((uint32) k[6] << 8);
/* fall through */
case 6: case 6:
b += ((uint32) k[5] << 16); b += ((uint32) k[5] << 16);
/* fall through */
case 5: case 5:
b += ((uint32) k[4] << 24); b += ((uint32) k[4] << 24);
/* fall through */
case 4: case 4:
a += k[3]; a += k[3];
/* fall through */
case 3: case 3:
a += ((uint32) k[2] << 8); a += ((uint32) k[2] << 8);
/* fall through */
case 2: case 2:
a += ((uint32) k[1] << 16); a += ((uint32) k[1] << 16);
/* fall through */
case 1: case 1:
a += ((uint32) k[0] << 24); a += ((uint32) k[0] << 24);
/* case 0: nothing left to add */ /* case 0: nothing left to add */
} }
#else /* !WORDS_BIGENDIAN */ #else /* !WORDS_BIGENDIAN */
switch (len) /* all the case statements fall through */ switch (len)
{ {
case 11: case 11:
c += ((uint32) k[10] << 24); c += ((uint32) k[10] << 24);
/* fall through */
case 10: case 10:
c += ((uint32) k[9] << 16); c += ((uint32) k[9] << 16);
/* fall through */
case 9: case 9:
c += ((uint32) k[8] << 8); c += ((uint32) k[8] << 8);
/* the lowest byte of c is reserved for the length */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += ((uint32) k[7] << 24); b += ((uint32) k[7] << 24);
/* fall through */
case 7: case 7:
b += ((uint32) k[6] << 16); b += ((uint32) k[6] << 16);
/* fall through */
case 6: case 6:
b += ((uint32) k[5] << 8); b += ((uint32) k[5] << 8);
/* fall through */
case 5: case 5:
b += k[4]; b += k[4];
/* fall through */
case 4: case 4:
a += ((uint32) k[3] << 24); a += ((uint32) k[3] << 24);
/* fall through */
case 3: case 3:
a += ((uint32) k[2] << 16); a += ((uint32) k[2] << 16);
/* fall through */
case 2: case 2:
a += ((uint32) k[1] << 8); a += ((uint32) k[1] << 8);
/* fall through */
case 1: case 1:
a += k[0]; a += k[0];
/* case 0: nothing left to add */ /* case 0: nothing left to add */
@ -686,9 +706,9 @@ hash_any_extended(register const unsigned char *k, register int keylen,
/* fall through */ /* fall through */
case 9: case 9:
c += ((uint32) k[8] << 24); c += ((uint32) k[8] << 24);
/* the lowest byte of c is reserved for the length */
/* fall through */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1]; b += ka[1];
a += ka[0]; a += ka[0];
break; break;
@ -725,9 +745,9 @@ hash_any_extended(register const unsigned char *k, register int keylen,
/* fall through */ /* fall through */
case 9: case 9:
c += ((uint32) k[8] << 8); c += ((uint32) k[8] << 8);
/* the lowest byte of c is reserved for the length */
/* fall through */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1]; b += ka[1];
a += ka[0]; a += ka[0];
break; break;
@ -778,57 +798,77 @@ hash_any_extended(register const unsigned char *k, register int keylen,
/* handle the last 11 bytes */ /* handle the last 11 bytes */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
switch (len) /* all the case statements fall through */ switch (len)
{ {
case 11: case 11:
c += ((uint32) k[10] << 8); c += ((uint32) k[10] << 8);
/* fall through */
case 10: case 10:
c += ((uint32) k[9] << 16); c += ((uint32) k[9] << 16);
/* fall through */
case 9: case 9:
c += ((uint32) k[8] << 24); c += ((uint32) k[8] << 24);
/* the lowest byte of c is reserved for the length */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += k[7]; b += k[7];
/* fall through */
case 7: case 7:
b += ((uint32) k[6] << 8); b += ((uint32) k[6] << 8);
/* fall through */
case 6: case 6:
b += ((uint32) k[5] << 16); b += ((uint32) k[5] << 16);
/* fall through */
case 5: case 5:
b += ((uint32) k[4] << 24); b += ((uint32) k[4] << 24);
/* fall through */
case 4: case 4:
a += k[3]; a += k[3];
/* fall through */
case 3: case 3:
a += ((uint32) k[2] << 8); a += ((uint32) k[2] << 8);
/* fall through */
case 2: case 2:
a += ((uint32) k[1] << 16); a += ((uint32) k[1] << 16);
/* fall through */
case 1: case 1:
a += ((uint32) k[0] << 24); a += ((uint32) k[0] << 24);
/* case 0: nothing left to add */ /* case 0: nothing left to add */
} }
#else /* !WORDS_BIGENDIAN */ #else /* !WORDS_BIGENDIAN */
switch (len) /* all the case statements fall through */ switch (len)
{ {
case 11: case 11:
c += ((uint32) k[10] << 24); c += ((uint32) k[10] << 24);
/* fall through */
case 10: case 10:
c += ((uint32) k[9] << 16); c += ((uint32) k[9] << 16);
/* fall through */
case 9: case 9:
c += ((uint32) k[8] << 8); c += ((uint32) k[8] << 8);
/* the lowest byte of c is reserved for the length */ /* fall through */
case 8: case 8:
/* the lowest byte of c is reserved for the length */
b += ((uint32) k[7] << 24); b += ((uint32) k[7] << 24);
/* fall through */
case 7: case 7:
b += ((uint32) k[6] << 16); b += ((uint32) k[6] << 16);
/* fall through */
case 6: case 6:
b += ((uint32) k[5] << 8); b += ((uint32) k[5] << 8);
/* fall through */
case 5: case 5:
b += k[4]; b += k[4];
/* fall through */
case 4: case 4:
a += ((uint32) k[3] << 24); a += ((uint32) k[3] << 24);
/* fall through */
case 3: case 3:
a += ((uint32) k[2] << 16); a += ((uint32) k[2] << 16);
/* fall through */
case 2: case 2:
a += ((uint32) k[1] << 8); a += ((uint32) k[1] << 8);
/* fall through */
case 1: case 1:
a += k[0]; a += k[0];
/* case 0: nothing left to add */ /* case 0: nothing left to add */

View File

@ -2092,6 +2092,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name list length must be at least %d", 3))); errmsg("name list length must be at least %d", 3)));
/* fall through to check args length */ /* fall through to check args length */
/* FALLTHROUGH */
case OBJECT_OPERATOR: case OBJECT_OPERATOR:
if (list_length(args) != 2) if (list_length(args) != 2)
ereport(ERROR, ereport(ERROR,

View File

@ -1479,7 +1479,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
case T_SampleScan: case T_SampleScan:
show_tablesample(((SampleScan *) plan)->tablesample, show_tablesample(((SampleScan *) plan)->tablesample,
planstate, ancestors, es); planstate, ancestors, es);
/* FALL THRU to print additional fields the same as SeqScan */ /* fall through to print additional fields the same as SeqScan */
/* FALLTHROUGH */
case T_SeqScan: case T_SeqScan:
case T_ValuesScan: case T_ValuesScan:
case T_CteScan: case T_CteScan:

View File

@ -440,6 +440,7 @@ DefineIndex(Oid relationId,
(errcode(ERRCODE_WRONG_OBJECT_TYPE), (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot create index on foreign table \"%s\"", errmsg("cannot create index on foreign table \"%s\"",
RelationGetRelationName(rel)))); RelationGetRelationName(rel))));
break;
default: default:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE), (errcode(ERRCODE_WRONG_OBJECT_TYPE),

View File

@ -3338,6 +3338,7 @@ ltrmark:;
case HeapTupleInvisible: case HeapTupleInvisible:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break;
default: default:
ReleaseBuffer(buffer); ReleaseBuffer(buffer);

View File

@ -2741,6 +2741,7 @@ EvalPlanQualFetch(EState *estate, Relation relation, int lockmode,
case HeapTupleInvisible: case HeapTupleInvisible:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break;
default: default:
ReleaseBuffer(buffer); ReleaseBuffer(buffer);

View File

@ -202,6 +202,7 @@ retry:
goto retry; goto retry;
case HeapTupleInvisible: case HeapTupleInvisible:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break;
default: default:
elog(ERROR, "unexpected heap_lock_tuple status: %u", res); elog(ERROR, "unexpected heap_lock_tuple status: %u", res);
break; break;
@ -365,6 +366,7 @@ retry:
goto retry; goto retry;
case HeapTupleInvisible: case HeapTupleInvisible:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break;
default: default:
elog(ERROR, "unexpected heap_lock_tuple status: %u", res); elog(ERROR, "unexpected heap_lock_tuple status: %u", res);
break; break;

View File

@ -256,6 +256,7 @@ lnext:
case HeapTupleInvisible: case HeapTupleInvisible:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break;
default: default:
elog(ERROR, "unrecognized heap_lock_tuple status: %u", elog(ERROR, "unrecognized heap_lock_tuple status: %u",

View File

@ -1390,6 +1390,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
/* This shouldn't happen */ /* This shouldn't happen */
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break;
case HeapTupleSelfUpdated: case HeapTupleSelfUpdated:
@ -1399,6 +1400,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
* seen this row to conflict with. * seen this row to conflict with.
*/ */
elog(ERROR, "unexpected self-updated tuple"); elog(ERROR, "unexpected self-updated tuple");
break;
case HeapTupleUpdated: case HeapTupleUpdated:
if (IsolationUsesXactSnapshot()) if (IsolationUsesXactSnapshot())

View File

@ -14855,18 +14855,21 @@ RoleId: RoleSpec
errmsg("role name \"%s\" is reserved", errmsg("role name \"%s\" is reserved",
"public"), "public"),
parser_errposition(@1))); parser_errposition(@1)));
break;
case ROLESPEC_SESSION_USER: case ROLESPEC_SESSION_USER:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_RESERVED_NAME), (errcode(ERRCODE_RESERVED_NAME),
errmsg("%s cannot be used as a role name here", errmsg("%s cannot be used as a role name here",
"SESSION_USER"), "SESSION_USER"),
parser_errposition(@1))); parser_errposition(@1)));
break;
case ROLESPEC_CURRENT_USER: case ROLESPEC_CURRENT_USER:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_RESERVED_NAME), (errcode(ERRCODE_RESERVED_NAME),
errmsg("%s cannot be used as a role name here", errmsg("%s cannot be used as a role name here",
"CURRENT_USER"), "CURRENT_USER"),
parser_errposition(@1))); parser_errposition(@1)));
break;
} }
} }
; ;

View File

@ -3829,12 +3829,14 @@ validateInfiniteBounds(ParseState *pstate, List *blist)
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("every bound following MAXVALUE must also be MAXVALUE"), errmsg("every bound following MAXVALUE must also be MAXVALUE"),
parser_errposition(pstate, exprLocation((Node *) prd)))); parser_errposition(pstate, exprLocation((Node *) prd))));
break;
case PARTITION_RANGE_DATUM_MINVALUE: case PARTITION_RANGE_DATUM_MINVALUE:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("every bound following MINVALUE must also be MINVALUE"), errmsg("every bound following MINVALUE must also be MINVALUE"),
parser_errposition(pstate, exprLocation((Node *) prd)))); parser_errposition(pstate, exprLocation((Node *) prd))));
break;
} }
} }
} }

View File

@ -875,6 +875,7 @@ lexescape(struct vars *v)
/* oops, doesn't look like it's a backref after all... */ /* oops, doesn't look like it's a backref after all... */
v->now = save; v->now = save;
/* and fall through into octal number */ /* and fall through into octal number */
/* FALLTHROUGH */
case CHR('0'): case CHR('0'):
NOTE(REG_UUNPORT); NOTE(REG_UUNPORT);
v->now--; /* put first digit back */ v->now--; /* put first digit back */

View File

@ -909,7 +909,8 @@ parseqatom(struct vars *v,
} }
/* legal in EREs due to specification botch */ /* legal in EREs due to specification botch */
NOTE(REG_UPBOTCH); NOTE(REG_UPBOTCH);
/* fallthrough into case PLAIN */ /* fall through into case PLAIN */
/* FALLTHROUGH */
case PLAIN: case PLAIN:
onechr(v, v->nextvalue, lp, rp); onechr(v, v->nextvalue, lp, rp);
okcolors(v->nfa, v->cm); okcolors(v->nfa, v->cm);

View File

@ -2762,7 +2762,8 @@ RecoveryConflictInterrupt(ProcSignalReason reason)
if (!IsWaitingForLock()) if (!IsWaitingForLock())
return; return;
/* Intentional drop through to check wait for pin */ /* Intentional fall through to check wait for pin */
/* FALLTHROUGH */
case PROCSIG_RECOVERY_CONFLICT_BUFFERPIN: case PROCSIG_RECOVERY_CONFLICT_BUFFERPIN:
@ -2775,7 +2776,8 @@ RecoveryConflictInterrupt(ProcSignalReason reason)
MyProc->recoveryConflictPending = true; MyProc->recoveryConflictPending = true;
/* Intentional drop through to error handling */ /* Intentional fall through to error handling */
/* FALLTHROUGH */
case PROCSIG_RECOVERY_CONFLICT_LOCK: case PROCSIG_RECOVERY_CONFLICT_LOCK:
case PROCSIG_RECOVERY_CONFLICT_TABLESPACE: case PROCSIG_RECOVERY_CONFLICT_TABLESPACE:
@ -2819,7 +2821,8 @@ RecoveryConflictInterrupt(ProcSignalReason reason)
break; break;
} }
/* Intentional drop through to session cancel */ /* Intentional fall through to session cancel */
/* FALLTHROUGH */
case PROCSIG_RECOVERY_CONFLICT_DATABASE: case PROCSIG_RECOVERY_CONFLICT_DATABASE:
RecoveryConflictPending = true; RecoveryConflictPending = true;

View File

@ -5216,6 +5216,7 @@ get_rolespec_tuple(const RoleSpec *role)
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("role \"%s\" does not exist", "public"))); errmsg("role \"%s\" does not exist", "public")));
tuple = NULL; /* make compiler happy */ tuple = NULL; /* make compiler happy */
break;
default: default:
elog(ERROR, "unexpected role type %d", role->roletype); elog(ERROR, "unexpected role type %d", role->roletype);

View File

@ -3146,7 +3146,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
* handle signed float numbers and signed year-month values. * handle signed float numbers and signed year-month values.
*/ */
/* FALL THROUGH */ /* FALLTHROUGH */
case DTK_DATE: case DTK_DATE:
case DTK_NUMBER: case DTK_NUMBER:
@ -3577,6 +3577,7 @@ DecodeISO8601Interval(char *str,
continue; continue;
} }
/* Else fall through to extended alternative format */ /* Else fall through to extended alternative format */
/* FALLTHROUGH */
case '-': /* ISO 8601 4.4.3.3 Alternative Format, case '-': /* ISO 8601 4.4.3.3 Alternative Format,
* Extended */ * Extended */
if (havefield) if (havefield)
@ -3655,6 +3656,7 @@ DecodeISO8601Interval(char *str,
return 0; return 0;
} }
/* Else fall through to extended alternative format */ /* Else fall through to extended alternative format */
/* FALLTHROUGH */
case ':': /* ISO 8601 4.4.3.3 Alternative Format, case ':': /* ISO 8601 4.4.3.3 Alternative Format,
* Extended */ * Extended */
if (havefield) if (havefield)

View File

@ -1522,6 +1522,7 @@ width_bucket_numeric(PG_FUNCTION_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), (errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION),
errmsg("lower bound cannot equal upper bound"))); errmsg("lower bound cannot equal upper bound")));
break;
/* bound1 < bound2 */ /* bound1 < bound2 */
case -1: case -1:

View File

@ -7481,8 +7481,8 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
return false; return false;
} }
/* else do the same stuff as for T_SubLink et al. */ /* else do the same stuff as for T_SubLink et al. */
/* FALL THROUGH */
} }
/* FALLTHROUGH */
case T_SubLink: case T_SubLink:
case T_NullTest: case T_NullTest:

View File

@ -3830,12 +3830,14 @@ timestamp_trunc(PG_FUNCTION_ARGS)
tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999; tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999;
else else
tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1; tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1;
/* FALL THRU */
case DTK_CENTURY: case DTK_CENTURY:
/* see comments in timestamptz_trunc */ /* see comments in timestamptz_trunc */
if (tm->tm_year > 0) if (tm->tm_year > 0)
tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99; tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99;
else else
tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1; tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1;
/* FALL THRU */
case DTK_DECADE: case DTK_DECADE:
/* see comments in timestamptz_trunc */ /* see comments in timestamptz_trunc */
if (val != DTK_MILLENNIUM && val != DTK_CENTURY) if (val != DTK_MILLENNIUM && val != DTK_CENTURY)
@ -3845,18 +3847,25 @@ timestamp_trunc(PG_FUNCTION_ARGS)
else else
tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10; tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10;
} }
/* FALL THRU */
case DTK_YEAR: case DTK_YEAR:
tm->tm_mon = 1; tm->tm_mon = 1;
/* FALL THRU */
case DTK_QUARTER: case DTK_QUARTER:
tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1; tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
/* FALL THRU */
case DTK_MONTH: case DTK_MONTH:
tm->tm_mday = 1; tm->tm_mday = 1;
/* FALL THRU */
case DTK_DAY: case DTK_DAY:
tm->tm_hour = 0; tm->tm_hour = 0;
/* FALL THRU */
case DTK_HOUR: case DTK_HOUR:
tm->tm_min = 0; tm->tm_min = 0;
/* FALL THRU */
case DTK_MINUTE: case DTK_MINUTE:
tm->tm_sec = 0; tm->tm_sec = 0;
/* FALL THRU */
case DTK_SECOND: case DTK_SECOND:
fsec = 0; fsec = 0;
break; break;
@ -4072,28 +4081,36 @@ interval_trunc(PG_FUNCTION_ARGS)
{ {
switch (val) switch (val)
{ {
/* fall through */
case DTK_MILLENNIUM: case DTK_MILLENNIUM:
/* caution: C division may have negative remainder */ /* caution: C division may have negative remainder */
tm->tm_year = (tm->tm_year / 1000) * 1000; tm->tm_year = (tm->tm_year / 1000) * 1000;
/* FALL THRU */
case DTK_CENTURY: case DTK_CENTURY:
/* caution: C division may have negative remainder */ /* caution: C division may have negative remainder */
tm->tm_year = (tm->tm_year / 100) * 100; tm->tm_year = (tm->tm_year / 100) * 100;
/* FALL THRU */
case DTK_DECADE: case DTK_DECADE:
/* caution: C division may have negative remainder */ /* caution: C division may have negative remainder */
tm->tm_year = (tm->tm_year / 10) * 10; tm->tm_year = (tm->tm_year / 10) * 10;
/* FALL THRU */
case DTK_YEAR: case DTK_YEAR:
tm->tm_mon = 0; tm->tm_mon = 0;
/* FALL THRU */
case DTK_QUARTER: case DTK_QUARTER:
tm->tm_mon = 3 * (tm->tm_mon / 3); tm->tm_mon = 3 * (tm->tm_mon / 3);
/* FALL THRU */
case DTK_MONTH: case DTK_MONTH:
tm->tm_mday = 0; tm->tm_mday = 0;
/* FALL THRU */
case DTK_DAY: case DTK_DAY:
tm->tm_hour = 0; tm->tm_hour = 0;
/* FALL THRU */
case DTK_HOUR: case DTK_HOUR:
tm->tm_min = 0; tm->tm_min = 0;
/* FALL THRU */
case DTK_MINUTE: case DTK_MINUTE:
tm->tm_sec = 0; tm->tm_sec = 0;
/* FALL THRU */
case DTK_SECOND: case DTK_SECOND:
fsec = 0; fsec = 0;
break; break;

View File

@ -5391,6 +5391,7 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
{ {
case GUC_SAVE: case GUC_SAVE:
Assert(false); /* can't get here */ Assert(false); /* can't get here */
break;
case GUC_SET: case GUC_SET:
/* next level always becomes SET */ /* next level always becomes SET */
@ -6257,7 +6258,8 @@ set_config_option(const char *name, const char *value,
name))); name)));
return 0; return 0;
} }
/* FALL THRU to process the same as PGC_BACKEND */ /* fall through to process the same as PGC_BACKEND */
/* FALLTHROUGH */
case PGC_BACKEND: case PGC_BACKEND:
if (context == PGC_SIGHUP) if (context == PGC_SIGHUP)
{ {

View File

@ -972,7 +972,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not seek in tuplestore temporary file: %m"))); errmsg("could not seek in tuplestore temporary file: %m")));
state->status = TSS_READFILE; state->status = TSS_READFILE;
/* FALL THRU into READFILE case */ /* FALLTHROUGH */
case TSS_READFILE: case TSS_READFILE:
*should_free = true; *should_free = true;

View File

@ -1978,6 +1978,8 @@ evalStandardFunc(TState *thread, CState *st,
Assert(0); Assert(0);
} }
} }
break; /* NOTREACHED */
} }
/* integer bitwise operators */ /* integer bitwise operators */

View File

@ -184,6 +184,7 @@ DecodeISO8601Interval(char *str,
continue; continue;
} }
/* Else fall through to extended alternative format */ /* Else fall through to extended alternative format */
/* FALLTHROUGH */
case '-': /* ISO 8601 4.4.3.3 Alternative Format, case '-': /* ISO 8601 4.4.3.3 Alternative Format,
* Extended */ * Extended */
if (havefield) if (havefield)
@ -262,6 +263,7 @@ DecodeISO8601Interval(char *str,
return 0; return 0;
} }
/* Else fall through to extended alternative format */ /* Else fall through to extended alternative format */
/* FALLTHROUGH */
case ':': /* ISO 8601 4.4.3.3 Alternative Format, case ':': /* ISO 8601 4.4.3.3 Alternative Format,
* Extended */ * Extended */
if (havefield) if (havefield)

View File

@ -189,8 +189,8 @@ main(int argc, char *const argv[])
break; break;
case 'h': case 'h':
header_mode = true; header_mode = true;
/* this must include "-c" to make sense */ /* this must include "-c" to make sense, so fall through */
/* so do not place a "break;" here */ /* FALLTHROUGH */
case 'c': case 'c':
auto_create_c = true; auto_create_c = true;
break; break;

View File

@ -3968,14 +3968,17 @@ exec_prepare_plan(PLpgSQL_execstate *estate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot COPY to/from client in PL/pgSQL"))); errmsg("cannot COPY to/from client in PL/pgSQL")));
break;
case SPI_ERROR_TRANSACTION: case SPI_ERROR_TRANSACTION:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot begin/end transactions in PL/pgSQL"), errmsg("cannot begin/end transactions in PL/pgSQL"),
errhint("Use a BEGIN block with an EXCEPTION clause instead."))); errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
break;
default: default:
elog(ERROR, "SPI_prepare_params failed for \"%s\": %s", elog(ERROR, "SPI_prepare_params failed for \"%s\": %s",
expr->query, SPI_result_code_string(SPI_result)); expr->query, SPI_result_code_string(SPI_result));
break;
} }
} }
if (keepplan) if (keepplan)
@ -4115,15 +4118,19 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot COPY to/from client in PL/pgSQL"))); errmsg("cannot COPY to/from client in PL/pgSQL")));
break;
case SPI_ERROR_TRANSACTION: case SPI_ERROR_TRANSACTION:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot begin/end transactions in PL/pgSQL"), errmsg("cannot begin/end transactions in PL/pgSQL"),
errhint("Use a BEGIN block with an EXCEPTION clause instead."))); errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
break;
default: default:
elog(ERROR, "SPI_execute_plan_with_paramlist failed executing query \"%s\": %s", elog(ERROR, "SPI_execute_plan_with_paramlist failed executing query \"%s\": %s",
expr->query, SPI_result_code_string(rc)); expr->query, SPI_result_code_string(rc));
break;
} }
/* All variants should save result info for GET DIAGNOSTICS */ /* All variants should save result info for GET DIAGNOSTICS */
@ -4299,11 +4306,14 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot COPY to/from client in PL/pgSQL"))); errmsg("cannot COPY to/from client in PL/pgSQL")));
break;
case SPI_ERROR_TRANSACTION: case SPI_ERROR_TRANSACTION:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot begin/end transactions in PL/pgSQL"), errmsg("cannot begin/end transactions in PL/pgSQL"),
errhint("Use a BEGIN block with an EXCEPTION clause instead."))); errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
break;
default: default:
elog(ERROR, "SPI_execute failed executing query \"%s\": %s", elog(ERROR, "SPI_execute failed executing query \"%s\": %s",

View File

@ -2451,7 +2451,8 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
Tcl_SetObjResult(interp, Tcl_NewIntObj(0)); Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
break; break;
} }
/* FALL THRU for utility returning tuples */ /* fall through for utility returning tuples */
/* FALLTHROUGH */
case SPI_OK_SELECT: case SPI_OK_SELECT:
case SPI_OK_INSERT_RETURNING: case SPI_OK_INSERT_RETURNING: