MCPcopy Create free account
hub / github.com/apache/cloudberry / PreventCommandIfReadOnly

Function PreventCommandIfReadOnly

src/backend/tcop/utility.c:468–483  ·  view source on GitHub ↗

* PreventCommandIfReadOnly: throw error if XactReadOnly * * This is useful partly to ensure consistency of the error message wording; * some callers have checked XactReadOnly for themselves. */

Source from the content-addressed store, hash-verified

466 * some callers have checked XactReadOnly for themselves.
467 */
468void
469PreventCommandIfReadOnly(const char *cmdname)
470{
471 if (XactReadOnly)
472 ereport(ERROR,
473 (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
474 /* translator: %s is name of a SQL command, eg CREATE */
475 errmsg("cannot execute %s in a read-only transaction",
476 cmdname)));
477
478 /*
479 * This is also a convenient place to make note that this transaction
480 * needs two-phase commit.
481 */
482 ExecutorMarkTransactionDoesWrites();
483}
484
485/*
486 * PreventCommandIfParallelMode: throw error if current (sub)transaction is

Callers 5

standard_ProcessUtilityFunction · 0.85
DoCopyFunction · 0.85
nextval_internalFunction · 0.85
do_setvalFunction · 0.85
ExecCheckXactReadOnlyFunction · 0.85

Calls 3

errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected