- Notifications
You must be signed in to change notification settings - Fork28
Commitc7cea26
committed
Replace empty locale name with implied value in CREATE DATABASE and initdb.
setlocale() accepts locale name "" as meaning "the locale specified by theprocess's environment variables". Historically we've accepted that forPostgres' locale settings, too. However, it's fairly unsafe to store anempty string in a new database's pg_database.datcollate or datctype fields,because then the interpretation could vary across postmaster restarts,possibly resulting in index corruption and other unpleasantness.Instead, we should expand "" to whatever it means at the moment of callingCREATE DATABASE, which we can do by saving the value returned bysetlocale().For consistency, make initdb set up the initial lc_xxx parameter values thesame way. initdb was already doing the right thing for empty locale names,but it did not replace non-empty names with setlocale results. On aplatform where setlocale chooses to canonicalize the spellings of localenames, this would result in annoying inconsistency. (It seems that popularimplementations of setlocale don't do such canonicalization, which is apity, but the POSIX spec certainly allows it to be done.) The same riskof inconsistency leads me to not venture back-patching this, although itcould certainly be seen as a longstanding bug.Per report from Jeff Davis, though this is not his proposed patch.1 parent8279eb4 commitc7cea26
File tree
4 files changed
+90
-41
lines changed- src
- backend
- commands
- utils/adt
- bin/initdb
- include/utils
4 files changed
+90
-41
lines changedLines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
| 126 | + | |
126 | 127 |
| |
127 | 128 |
| |
128 | 129 |
| |
| |||
318 | 319 |
| |
319 | 320 |
| |
320 | 321 |
| |
321 |
| - | |
322 |
| - | |
| 322 | + | |
| 323 | + | |
323 | 324 |
| |
324 | 325 |
| |
325 | 326 |
| |
326 |
| - | |
| 327 | + | |
| 328 | + | |
327 | 329 |
| |
328 | 330 |
| |
329 | 331 |
| |
| 332 | + | |
330 | 333 |
| |
331 | 334 |
| |
332 | 335 |
| |
|
Lines changed: 24 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
222 | 222 |
| |
223 | 223 |
| |
224 | 224 |
| |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
225 | 232 |
| |
226 | 233 |
| |
227 |
| - | |
| 234 | + | |
228 | 235 |
| |
229 | 236 |
| |
230 |
| - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
231 | 241 |
| |
232 | 242 |
| |
233 | 243 |
| |
234 | 244 |
| |
235 | 245 |
| |
236 |
| - | |
| 246 | + | |
237 | 247 |
| |
238 | 248 |
| |
239 | 249 |
| |
240 |
| - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
241 | 255 |
| |
242 | 256 |
| |
243 | 257 |
| |
244 |
| - | |
| 258 | + | |
245 | 259 |
| |
246 | 260 |
| |
247 |
| - | |
| 261 | + | |
248 | 262 |
| |
249 | 263 |
| |
250 | 264 |
| |
| |||
262 | 276 |
| |
263 | 277 |
| |
264 | 278 |
| |
265 |
| - | |
| 279 | + | |
266 | 280 |
| |
267 | 281 |
| |
268 | 282 |
| |
| |||
274 | 288 |
| |
275 | 289 |
| |
276 | 290 |
| |
277 |
| - | |
| 291 | + | |
278 | 292 |
| |
279 | 293 |
| |
280 | 294 |
| |
| |||
286 | 300 |
| |
287 | 301 |
| |
288 | 302 |
| |
289 |
| - | |
| 303 | + | |
290 | 304 |
| |
291 | 305 |
| |
292 | 306 |
| |
| |||
322 | 336 |
| |
323 | 337 |
| |
324 | 338 |
| |
325 |
| - | |
| 339 | + | |
326 | 340 |
| |
327 | 341 |
| |
328 | 342 |
| |
|
Lines changed: 59 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
213 | 213 |
| |
214 | 214 |
| |
215 | 215 |
| |
216 |
| - | |
| 216 | + | |
| 217 | + | |
217 | 218 |
| |
218 | 219 |
| |
219 | 220 |
| |
| |||
2240 | 2241 |
| |
2241 | 2242 |
| |
2242 | 2243 |
| |
2243 |
| - | |
| 2244 | + | |
2244 | 2245 |
| |
2245 |
| - | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
2246 | 2254 |
| |
2247 | 2255 |
| |
2248 |
| - | |
| 2256 | + | |
2249 | 2257 |
| |
2250 |
| - | |
2251 |
| - | |
2252 | 2258 |
| |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
2253 | 2263 |
| |
2254 | 2264 |
| |
2255 | 2265 |
| |
2256 |
| - | |
| 2266 | + | |
2257 | 2267 |
| |
| 2268 | + | |
2258 | 2269 |
| |
2259 | 2270 |
| |
2260 |
| - | |
| 2271 | + | |
| 2272 | + | |
2261 | 2273 |
| |
2262 |
| - | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
2263 | 2282 |
| |
2264 | 2283 |
| |
2265 | 2284 |
| |
2266 |
| - | |
2267 |
| - | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
2268 | 2288 |
| |
2269 |
| - | |
| 2289 | + | |
2270 | 2290 |
| |
2271 | 2291 |
| |
2272 | 2292 |
| |
| |||
2308 | 2328 |
| |
2309 | 2329 |
| |
2310 | 2330 |
| |
2311 |
| - | |
| 2331 | + | |
2312 | 2332 |
| |
2313 | 2333 |
| |
2314 | 2334 |
| |
2315 | 2335 |
| |
| 2336 | + | |
| 2337 | + | |
2316 | 2338 |
| |
2317 | 2339 |
| |
2318 | 2340 |
| |
| |||
2332 | 2354 |
| |
2333 | 2355 |
| |
2334 | 2356 |
| |
2335 |
| - | |
| 2357 | + | |
| 2358 | + | |
2336 | 2359 |
| |
2337 | 2360 |
| |
2338 |
| - | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
2339 | 2364 |
| |
2340 |
| - | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
2341 | 2368 |
| |
2342 |
| - | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
2343 | 2372 |
| |
2344 |
| - | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
2345 | 2376 |
| |
2346 |
| - | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
2347 | 2380 |
| |
2348 |
| - | |
2349 | 2381 |
| |
2350 |
| - | |
2351 |
| - | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
2352 | 2385 |
| |
2353 |
| - | |
2354 | 2386 |
| |
2355 |
| - | |
2356 |
| - | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
2357 | 2391 |
| |
2358 |
| - | |
2359 | 2392 |
| |
2360 |
| - | |
2361 | 2393 |
| |
2362 | 2394 |
| |
2363 | 2395 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
|
0 commit comments
Comments
(0)