| 732 | } |
| 733 | |
| 734 | void |
| 735 | assign_client_encoding(const char *newval, void *extra) |
| 736 | { |
| 737 | int encoding = *((int *) extra); |
| 738 | |
| 739 | /* |
| 740 | * Parallel workers send data to the leader, not the client. They always |
| 741 | * send data using the database encoding. |
| 742 | */ |
| 743 | if (IsParallelWorker()) |
| 744 | { |
| 745 | /* |
| 746 | * During parallel worker startup, we want to accept the leader's |
| 747 | * client_encoding setting so that anyone who looks at the value in |
| 748 | * the worker sees the same value that they would see in the leader. |
| 749 | */ |
| 750 | if (InitializingParallelWorker) |
| 751 | return; |
| 752 | |
| 753 | /* |
| 754 | * A change other than during startup, for example due to a SET clause |
| 755 | * attached to a function definition, should be rejected, as there is |
| 756 | * nothing we can do inside the worker to make it take effect. |
| 757 | */ |
| 758 | ereport(ERROR, |
| 759 | (errcode(ERRCODE_INVALID_TRANSACTION_STATE), |
| 760 | errmsg("cannot change client_encoding during a parallel operation"))); |
| 761 | } |
| 762 | |
| 763 | /* We do not expect an error if PrepareClientEncoding succeeded */ |
| 764 | if (SetClientEncoding(encoding) < 0) |
| 765 | elog(LOG, "SetClientEncoding(%d) failed", encoding); |
| 766 | } |
| 767 | |
| 768 | |
| 769 | /* |
nothing calls this directly
no test coverage detected