forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0b13b2a
committed
Rethink behavior of pg_import_system_collations().
Marco Atzeri reported that initdb would fail if "locale -a" reportedthe same locale name more than once. All previous versions of Postgresimplicitly de-duplicated the results of "locale -a", but the rewriteto move the collation import logic into C had lost that property.It had also lost the property that locale names matching built-incollation names were silently ignored.The simplest way to fix this is to make initdb run the function inif-not-exists mode, which means that there's no real use-case fornon if-not-exists mode; we might as well just drop the boolean argumentand simplify the function's definition to be "add any collations notalready known". This change also gets rid of some odd corner casescaused by the fact that aliases were added in if-not-exists mode evenif the function argument said otherwise.While at it, adjust the behavior so that pg_import_system_collations()doesn't spew "collation foo already exists, skipping" messages during are-run; that's completely unhelpful, especially since there are oftenhundreds of them. And make it return a count of the number of collationsit did add, which seems like it might be helpful.Also, re-integrate the previous coding's property that it would make adeterministic selection of which alias to use if there were conflictingpossibilities. This would only come into play if "locale -a" reportsmultiple equivalent locale names, say "de_DE.utf8" and "de_DE.UTF-8",but that hardly seems out of the question.In passing, fix incorrect behavior in pg_import_system_collations()'sICU code path: it neglected CommandCounterIncrement, which would resultin failures if ICU returns duplicate names, and it would try to createcomments even if a new collation hadn't been created.Also, reorder operations in initdb so that the 'ucs_basic' collationis created before calling pg_import_system_collations() not after.This prevents a failure if "locale -a" were to report a locale namedthat. There's no reason to think that that ever happens in the wild,but the old coding would have survived it, so let's be equally robust.Discussion:https://postgr.es/m/20c74bc3-d6ca-243d-1bbc-12f17fa4fe9a@gmail.com1 parent9ea3c64 commit0b13b2a
File tree
7 files changed
+254
-138
lines changed- doc/src/sgml
- src
- backend
- catalog
- commands
- bin/initdb
- include/catalog
7 files changed
+254
-138
lines changedLines changed: 13 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19711 | 19711 |
| |
19712 | 19712 |
| |
19713 | 19713 |
| |
19714 |
| - | |
| 19714 | + | |
19715 | 19715 |
| |
19716 |
| - | |
| 19716 | + | |
19717 | 19717 |
| |
19718 | 19718 |
| |
19719 | 19719 |
| |
| |||
19730 | 19730 |
| |
19731 | 19731 |
| |
19732 | 19732 |
| |
19733 |
| - | |
19734 |
| - | |
19735 |
| - | |
| 19733 | + | |
| 19734 | + | |
| 19735 | + | |
19736 | 19736 |
| |
19737 | 19737 |
| |
19738 | 19738 |
| |
19739 |
| - | |
19740 |
| - | |
19741 |
| - | |
19742 |
| - | |
19743 |
| - | |
19744 |
| - | |
| 19739 | + | |
| 19740 | + | |
| 19741 | + | |
| 19742 | + | |
| 19743 | + | |
| 19744 | + | |
| 19745 | + | |
| 19746 | + | |
19745 | 19747 |
| |
19746 | 19748 |
| |
19747 | 19749 |
| |
|
Lines changed: 16 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 |
| |
41 | 46 |
| |
42 | 47 |
| |
| |||
45 | 50 |
| |
46 | 51 |
| |
47 | 52 |
| |
48 |
| - | |
| 53 | + | |
| 54 | + | |
49 | 55 |
| |
50 | 56 |
| |
51 | 57 |
| |
| |||
77 | 83 |
| |
78 | 84 |
| |
79 | 85 |
| |
80 |
| - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
81 | 89 |
| |
82 | 90 |
| |
83 | 91 |
| |
| |||
119 | 127 |
| |
120 | 128 |
| |
121 | 129 |
| |
122 |
| - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
123 | 136 |
| |
124 | 137 |
| |
125 | 138 |
| |
|
0 commit comments
Comments
(0)