I use ecpg to query how many pieces of data there are in the table, the code is as follows
EXEC SQL BEGIN DECLARE SECTION;
long tblCnt;
EXEC SQL END DECLARE SECTION;
EXEC SQL
SELECT
COUNT(*)
INTO
:tblCnt
FROM
MY_TABLE;
If the data in the table is 217991, the query is normal. If it is greater than or equal to 217992, it will be abnormal.
This is the abnormal log (the data in the table is different except for the first column item_id, and the data in other columns are the same)
2022-10-20 08:38:54.571 GMT [1961839] ERROR: invalid value for parameter "client_encoding": "SJIS"
2022-10-20 08:38:54.571 GMT [1961839] DETAIL: Conversion between SJIS and UTF8 is not supported.
2022-10-20 08:38:54.571 GMT [1961839] CONTEXT: while setting parameter "client_encoding" to "SJIS"
2022-10-20 08:38:54.571 GMT [1961838] ERROR: invalid value for parameter "client_encoding": "SJIS"
2022-10-20 08:38:54.571 GMT [1961838] DETAIL: Conversion between SJIS and UTF8 is not supported.
2022-10-20 08:38:54.571 GMT [1961838] CONTEXT: while setting parameter "client_encoding" to "SJIS"
2022-10-20 16:38:54.571 CST [1961825] ERROR: invalid value for parameter "client_encoding": "SJIS"
2022-10-20 16:38:54.571 CST [1961825] DETAIL: Conversion between SJIS and UTF8 is not supported.
2022-10-20 16:38:54.571 CST [1961825] CONTEXT: while setting parameter "client_encoding" to "SJIS"
parallel worker
2022-10-20 16:38:54.571 CST [1961825] STATEMENT: select count ( * ) from MY_TABLE
2022-10-20 16:38:54.572 CST [611663] LOG: background worker "parallel worker" (PID 1961838) exited with exit code 1
2022-10-20 16:38:54.572 CST [611663] LOG: background worker "parallel worker" (PID 1961839) exited with exit code 1
Environment variables set before running
export LANG=ja_JP.sjis
export PGCLIENTENCODING=SJIS
database character set
pgdb=> show server_encoding;
server_encoding
-----------------
UTF8
Database version is 13.5
I queried in www.postgresql.jp/document/13/html/multibyte.html that the server UTF8 character set supports conversion to all client character sets. If the character set is wrong, why is there no error in the first line?
count(*) is counted on the server, why is there a character set conversion error?
Please tell me any possible reason, thanks