Skip to content

Commit 9c679a0

Browse files
committed
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.
1 parent 7aaefad commit 9c679a0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/backend/tcop/utility.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ CommandIsReadOnly(PlannedStmt *pstmt)
129129
*
130130
* Note the definitions of the relevant flags in src/include/utility/tcop.h.
131131
*/
132-
int
132+
static int
133133
ClassifyUtilityCommandAsReadOnly(Node *parsetree)
134134
{
135135
switch (nodeTag(parsetree))
@@ -359,7 +359,7 @@ ClassifyUtilityCommandAsReadOnly(Node *parsetree)
359359
TransactionStmt *stmt = (TransactionStmt *) parsetree;
360360

361361
/*
362-
* PREPARE, COMMIT PREPARED, and ROLLBACK PREPARED all change
362+
* PREPARE, COMMIT PREPARED, and ROLLBACK PREPARED all
363363
* write WAL, so they're not read-only in the strict sense;
364364
* but the first and third do not change pg_dump output, so
365365
* they're OK in a read-only transactions.
@@ -383,12 +383,15 @@ ClassifyUtilityCommandAsReadOnly(Node *parsetree)
383383
case TRANS_STMT_ROLLBACK_PREPARED:
384384
return COMMAND_OK_IN_READ_ONLY_TXN;
385385
}
386+
elog(ERROR, "unrecognized TransactionStmtKind: %d",
387+
(int) stmt->kind);
388+
return 0; /* silence stupider compilers */
386389
}
387390

388391
default:
389392
elog(ERROR, "unrecognized node type: %d",
390393
(int) nodeTag(parsetree));
391-
break;
394+
return 0; /* silence stupider compilers */
392395
}
393396
}
394397

src/backend/utils/adt/jsonfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4456,6 +4456,7 @@ jsonb_set_lax(PG_FUNCTION_ARGS)
44564456
ereport(ERROR,
44574457
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
44584458
errmsg("need delete_key, return_target, use_json_null, or raise_exception")));
4459+
return (Datum) 0; /* silence stupider compilers */
44594460
}
44604461
}
44614462

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy