Silence minor compiler warnings.

Ensure that ClassifyUtilityCommandAsReadOnly() has defined behavior
even if TransactionStmt.kind has a value that's not one of the
declared values for its enum.

Suppress warnings from compilers that don't know that elog(ERROR)
doesn't return, in ClassifyUtilityCommandAsReadOnly() and
jsonb_set_lax().

Per Coverity and buildfarm.
This commit is contained in:
Tom Lane 2020-01-19 16:04:36 -05:00
parent 7aaefadaac
commit 9c679a08f0
2 changed files with 7 additions and 3 deletions

View File

@ -129,7 +129,7 @@ CommandIsReadOnly(PlannedStmt *pstmt)
* *
* Note the definitions of the relevant flags in src/include/utility/tcop.h. * Note the definitions of the relevant flags in src/include/utility/tcop.h.
*/ */
int static int
ClassifyUtilityCommandAsReadOnly(Node *parsetree) ClassifyUtilityCommandAsReadOnly(Node *parsetree)
{ {
switch (nodeTag(parsetree)) switch (nodeTag(parsetree))
@ -359,7 +359,7 @@ ClassifyUtilityCommandAsReadOnly(Node *parsetree)
TransactionStmt *stmt = (TransactionStmt *) parsetree; TransactionStmt *stmt = (TransactionStmt *) parsetree;
/* /*
* PREPARE, COMMIT PREPARED, and ROLLBACK PREPARED all change * PREPARE, COMMIT PREPARED, and ROLLBACK PREPARED all
* write WAL, so they're not read-only in the strict sense; * write WAL, so they're not read-only in the strict sense;
* but the first and third do not change pg_dump output, so * but the first and third do not change pg_dump output, so
* they're OK in a read-only transactions. * they're OK in a read-only transactions.
@ -383,12 +383,15 @@ ClassifyUtilityCommandAsReadOnly(Node *parsetree)
case TRANS_STMT_ROLLBACK_PREPARED: case TRANS_STMT_ROLLBACK_PREPARED:
return COMMAND_OK_IN_READ_ONLY_TXN; return COMMAND_OK_IN_READ_ONLY_TXN;
} }
elog(ERROR, "unrecognized TransactionStmtKind: %d",
(int) stmt->kind);
return 0; /* silence stupider compilers */
} }
default: default:
elog(ERROR, "unrecognized node type: %d", elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(parsetree)); (int) nodeTag(parsetree));
break; return 0; /* silence stupider compilers */
} }
} }

View File

@ -4456,6 +4456,7 @@ jsonb_set_lax(PG_FUNCTION_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("need delete_key, return_target, use_json_null, or raise_exception"))); errmsg("need delete_key, return_target, use_json_null, or raise_exception")));
return (Datum) 0; /* silence stupider compilers */
} }
} }