auto-detect locale from old cluster during upgrade#52
auto-detect locale from old cluster during upgrade#52pkhartsk wants to merge 3 commits intodevexp-db:masterfrom
Conversation
Automatically detect and preserve locale settings (lc_collate, lc_ctype) from the old PostgreSQL cluster during upgrade operations. This fixes upgrade failures when system locale has changed between initialization and upgrade. The implementation queries locale from the old cluster's template1 database, temporarily starting the server if needed. Detected locale values are automatically passed to initdb via PGSETUP_INITDB_OPTIONS. Fixes: Bug 1152556
268116e to
5c19c23
Compare
Replaced check for running postgres with failure in `detect_old_locale`, since the script would fail later anyway, so there's no reason to have extra code that does nothing. Fixed `psql` being run from the old pg bin directory. Wrote a test for the script.
|
I looked at the changes in detect_old_cluster_locale() and I think there are few issues with how the running server check is done now. Using old_data_in_use() inside detect_old_cluster_locale() is problematic:
I think better approach would be to move the running-server check to the beginning of upgrade() with immediate exit, before detect_old_cluster_locale() gets called. Then detect_old_cluster_locale() doesn't need the old_data_in_use check at all — it can just assume server is not running and do its job (start temp server, query, stop). This way:
One more thing — psql path |
Updated 'old_data_in_use()' to check if postgres is running, but exit either way even if there is just an orphan pidfile. This only runs once at the beginning of 'upgrade()' to fail fast. Use new psql's full path instead of realying on $PATH.
|
LGTM lest's wait for test results |
including tests