Repository navigation
fix: pg0 start no longer fails on Chinese-locale Windows - #52
Merged
Merged
Conversation
On Chinese Windows, PostgreSQL writes the data directory path in postmaster.pid in the ANSI code page (GBK). pg0 read the file as strict UTF-8, so start failed with 'stream did not contain valid UTF-8'. Read it, the log tail and pg0 logs loosely. Fixes #46.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #46.
Cause: after starting the server,
pg0 startreadspostmaster.pidto get the pid. Line 2 of that file is the data directory path, which PostgreSQL on Windows writes in the ANSI code page (GBK on zh-CN). pg0 read the file as strict UTF-8, so any non-ASCII character in the path (for example a Chinese username inC:\Users\…\.pg0) failed withIO error: stream did not contain valid UTF-8. That is the exact error in the report. pg0 only needs line 1.Fix: read
postmaster.pid, the startup-failure log tail, andpg0 logsloosely (invalid bytes become�), so an odd encoding can't break startup or log viewing.I didn't add
LC_MESSAGES=C: new clusters already getlc_messages = C, andpostgresql_embeddedalready decodes tool output loosely.Test:
postmaster_pid_with_non_utf8_path_is_readablewrites apostmaster.pidwith a GBK path. On the old code it fails with the samestream did not contain valid UTF-8error, and it passes with this change. Full suite: 17/17. Not tested on a real zh-CN Windows machine.