* PreventCommandIfReadOnly: throw error if XactReadOnly * * This is useful partly to ensure consistency of the error message wording; * some callers have checked XactReadOnly for themselves. */
| 466 | * some callers have checked XactReadOnly for themselves. |
| 467 | */ |
| 468 | void |
| 469 | PreventCommandIfReadOnly(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 |
no test coverage detected