fix: handle localized duplicate-database errors on restart (#13)#15
Merged
Conversation
`pg0 start` failed to restart an existing instance when PostgreSQL returned a localized duplicate-database error (e.g. on Windows with a Chinese locale: `数据库 "x" 已经存在`). The previous logic relied on the English substring `already exists` to swallow the error, which never matched on non-English builds. Replaced the post-hoc string match with a `database_exists()` pre-check so the create path is locale-independent, and added a Python regression test that starts → stops → restarts an instance with a custom database.
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.
Summary
pg0 startfailed to restart an existing instance when PostgreSQL returned a localized duplicate-database error (e.g. on Windows with a Chinese locale:数据库 "x" 已经存在). The startup logic only matched the English substringalready exists, so non-English builds raised on the second start.database_exists()pre-check so the create path is locale-independent.test_restart_with_custom_database) that starts → stops → restarts an instance with a custom database and verifies data survives.Fixes #13.
Test plan
cargo buildcompiles cleanlysdk/python/tests/test_pg0.py)database "testdb" already exists