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

Function assign_client_encoding

src/backend/commands/variable.c:734–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732}
733
734void
735assign_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/*

Callers

nothing calls this directly

Calls 3

SetClientEncodingFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected