Skip to content

fix: handle localized duplicate-database errors on restart (#13)#15

Merged
nicoloboschi merged 1 commit into
mainfrom
fix/localized-duplicate-db-error
May 8, 2026
Merged

fix: handle localized duplicate-database errors on restart (#13)#15
nicoloboschi merged 1 commit into
mainfrom
fix/localized-duplicate-db-error

Conversation

@nicoloboschi
Copy link
Copy Markdown
Collaborator

Summary

  • 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 startup logic only matched the English substring already exists, so non-English builds raised on the second start.
  • Replaced the post-hoc error-string match with a database_exists() pre-check so the create path is locale-independent.
  • Added a Python regression test (test_restart_with_custom_database) that starts → stops → restarts an instance with a custom database and verifies data survives.

Fixes #13.

Test plan

  • cargo build compiles cleanly
  • New regression test passes against the fixed binary (16/16 in sdk/python/tests/test_pg0.py)
  • Verified the same test fails on the unfixed binary with database "testdb" already exists

`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.
@nicoloboschi nicoloboschi merged commit f543502 into main May 8, 2026
15 checks passed
@nicoloboschi nicoloboschi deleted the fix/localized-duplicate-db-error branch May 8, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pg0 fails to restart existing instance on localized PostgreSQL duplicate database error

1 participant