Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 42dfb2d

Browse files
committed
Merge branch 'PGPRO10' into PGPROEE10_DEV
2 parents 6fdd531 + ec415b9 commit 42dfb2d

File tree

11 files changed

+949
-748
lines changed

11 files changed

+949
-748
lines changed

doc/src/sgml/demodb-bookings-schema.svg

Lines changed: 225 additions & 277 deletions
Loading

doc/src/sgml/demodb-bookings.sgml

Lines changed: 272 additions & 156 deletions
Large diffs are not rendered by default.

src/backend/commands/dbcommands.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
153153
char *icu_wincollate = NULL;
154154
char *langtag = NULL;
155155
const char *collate;
156-
#ifdef WIN32
157-
char *dbcollate_original;
158-
char *dbctype_original;
159-
#endif
160156

161157
/* Extract options from the statement node tree */
162158
foreach(option, stmt->options)
@@ -399,11 +395,6 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
399395

400396
/* Check that the chosen locales are valid, and get canonical spellings */
401397

402-
#ifdef WIN32
403-
dbcollate_original = dbcollate;
404-
dbctype_original = dbctype;
405-
#endif
406-
407398
if (!check_locale(LC_CTYPE, dbctype, &canonname, '\0'))
408399
ereport(ERROR,
409400
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -440,15 +431,6 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
440431
/* check lc_collate and lc_ctype for icu if we need it */
441432
if (dbcollprovider == COLLPROVIDER_ICU)
442433
{
443-
#ifdef WIN32
444-
/* set the libc canonnames for dbcollate and dbctype */
445-
446-
check_winlocale(dbcollate_original, &canonname, NULL);
447-
dbcollate = canonname;
448-
449-
check_winlocale(dbctype_original, &canonname, NULL);
450-
dbctype = canonname;
451-
#endif
452434
if (!check_locale(LC_COLLATE, dbcollate, NULL, dbcollprovider))
453435
ereport(ERROR,
454436
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -468,20 +450,19 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
468450
#ifdef USE_ICU
469451
if (dbcollprovider == COLLPROVIDER_ICU)
470452
{
453+
collate = (const char *) dbcollate;
471454
#ifdef WIN32
472-
if (!locale_is_c(dbcollate))
455+
if (!locale_is_c(collate))
473456
{
474-
check_winlocale(dbcollate, NULL, &icu_wincollate);
457+
icu_wincollate = check_icu_winlocale(collate);
475458
collate = (const char *) icu_wincollate;
476459
}
477-
#else /* not WIN32 */
478-
collate = (const char *) dbcollate;
479-
#endif /* not WIN32 */
460+
#endif /* WIN32 */
480461
langtag = get_icu_language_tag(collate);
481462
collate = get_icu_collate(collate, langtag);
482463
}
483464
else
484-
#endif
465+
#endif /* USE_ICU */
485466
{
486467
/* COLLPROVIDER_LIBC */
487468
collate = (const char *) dbcollate;

src/backend/utils/adt/pg_locale.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,6 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen,
18361836
* If locale is "" return the environment value from setlocale().
18371837
*
18381838
* Otherwise return a malloc'd copy of locale if it is not NULL.
1839-
*
1840-
* In Windows, check that the name is not long (for example,
1841-
* "English_United States[.encoding]").
18421839
*/
18431840
static char *
18441841
check_icu_locale(const char *locale)
@@ -1847,19 +1844,20 @@ check_icu_locale(const char *locale)
18471844
char *winlocale = NULL;
18481845
char *result;
18491846

1847+
/* Windows locales can be in the format ".codepage" */
1848+
if (locale && (strlen(locale) == 0 || locale[0] == '.'))
1849+
{
1850+
check_locale(LC_COLLATE, locale, &canonname, COLLPROVIDER_LIBC);
1851+
locale = (const char *) canonname;
1852+
}
1853+
18501854
#ifdef WIN32
18511855
if (!locale_is_c(locale))
18521856
{
1853-
check_winlocale(locale, NULL, &winlocale);
1857+
winlocale = check_icu_winlocale(locale);
18541858
locale = (const char *) winlocale;
18551859
}
1856-
#else /* not WIN32 */
1857-
if (locale && strlen(locale) == 0)
1858-
{
1859-
check_locale(LC_COLLATE, locale, &canonname, COLLPROVIDER_LIBC);
1860-
locale = (const char *) canonname;
1861-
}
1862-
#endif /* not WIN32 */
1860+
#endif
18631861

18641862
result = locale ? pstrdup(locale) : NULL;
18651863

src/backend/utils/init/postinit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,15 @@ CheckMyDatabase(const char *name, bool am_superuser)
442442
#ifdef WIN32
443443
if (!locale_is_c(collcollate))
444444
{
445-
check_winlocale(collcollate, NULL, &wincollate);
445+
wincollate = check_icu_winlocale(collcollate);
446446
collcollate = (const char *) wincollate;
447447
}
448448
#endif /* WIN32 */
449449
langtag = get_icu_language_tag(collcollate);
450450
collcollate = get_icu_collate(collcollate, langtag);
451451
}
452452
else
453-
#endif
453+
#endif /* USE_ICU */
454454
{
455455
/* COLLPROVIDER_LIBC */
456456
collcollate = (const char *) collate;

src/bin/initdb/initdb.c

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,10 +2363,6 @@ static void
23632363
setlocales(void)
23642364
{
23652365
char *canonname;
2366-
#ifdef WIN32
2367-
char *lc_collate_original;
2368-
char *lc_ctype_original;
2369-
#endif
23702366

23712367
/*
23722368
* Set up the collation provider if possible and canonicalize the locale
@@ -2415,11 +2411,6 @@ setlocales(void)
24152411
* current environment
24162412
*/
24172413

2418-
#ifdef WIN32
2419-
lc_collate_original = pstrdup(lc_collate);
2420-
lc_ctype_original = pstrdup(lc_ctype);
2421-
#endif
2422-
24232414
check_locale_name(LC_CTYPE, lc_ctype, &canonname, '\0');
24242415
lc_ctype = canonname;
24252416

@@ -2448,23 +2439,6 @@ setlocales(void)
24482439
/* check lc_collate and lc_ctype for icu if we need it */
24492440
if (collprovider == COLLPROVIDER_ICU)
24502441
{
2451-
#ifdef WIN32
2452-
/* set the libc canonnames for lc_collate and lc_ctype */
2453-
2454-
check_winlocale(lc_collate_original, &canonname, NULL);
2455-
if (canonname == NULL && lc_collate_original != NULL)
2456-
exit(1); /* check_winlocale printed the error */
2457-
2458-
pfree(lc_collate);
2459-
lc_collate = canonname;
2460-
2461-
check_winlocale(lc_ctype_original, &canonname, NULL);
2462-
if (canonname == NULL && lc_ctype_original != NULL)
2463-
exit(1); /* check_winlocale printed the error */
2464-
2465-
pfree(lc_ctype);
2466-
lc_ctype = canonname;
2467-
#endif
24682442
check_locale_name(LC_COLLATE, lc_collate, NULL, collprovider);
24692443
if (strcmp(lc_collate, lc_ctype) != 0)
24702444
{
@@ -2491,11 +2465,6 @@ setlocales(void)
24912465
#endif
24922466

24932467
set_collation_version();
2494-
2495-
#ifdef WIN32
2496-
free(lc_collate_original);
2497-
free(lc_ctype_original);
2498-
#endif
24992468
}
25002469

25012470
/*
@@ -3564,9 +3533,6 @@ main(int argc, char *argv[])
35643533
*
35653534
* Otherwise return a malloc'd copy of locale if it is not NULL.
35663535
*
3567-
* In Windows, check that the name is not long (for example,
3568-
* "English_United States[.encoding]").
3569-
*
35703536
* This should match the backend's check_icu_locale() function.
35713537
*/
35723538
static char *
@@ -3576,23 +3542,24 @@ check_icu_locale_name(const char *locale)
35763542
char *winlocale = NULL;
35773543
char *result;
35783544

3545+
/* Windows locales can be in the format ".codepage" */
3546+
if (locale && (strlen(locale) == 0 || locale[0] == '.'))
3547+
{
3548+
check_locale_name(LC_COLLATE, locale, &canonname, COLLPROVIDER_LIBC);
3549+
locale = (const char *) canonname;
3550+
}
3551+
35793552
#ifdef WIN32
35803553
if (!locale_is_c(locale))
35813554
{
3582-
check_winlocale(locale, NULL, &winlocale);
3555+
winlocale = check_icu_winlocale(locale);
35833556

35843557
if (winlocale == NULL && locale != NULL)
3585-
exit(1); /* check_winlocale printed the error */
3558+
exit(1); /* check_icu_winlocale printed the error */
35863559
else
35873560
locale = winlocale;
35883561
}
3589-
#else /* not WIN32 */
3590-
if (locale && strlen(locale) == 0)
3591-
{
3592-
check_locale_name(LC_COLLATE, locale, &canonname, COLLPROVIDER_LIBC);
3593-
locale = (const char *) canonname;
3594-
}
3595-
#endif /* not WIN32 */
3562+
#endif
35963563

35973564
result = locale ? pstrdup(locale) : NULL;
35983565

@@ -3621,19 +3588,19 @@ set_collation_version(void)
36213588
if (collprovider == COLLPROVIDER_ICU)
36223589
{
36233590
#ifdef USE_ICU
3591+
collate = (const char *) lc_collate;
3592+
36243593
#ifdef WIN32
3625-
if (!locale_is_c(lc_collate))
3594+
if (!locale_is_c(collate))
36263595
{
3627-
check_winlocale(lc_collate, NULL, &wincollate);
3596+
wincollate = check_icu_winlocale(collate);
36283597

3629-
if (wincollate == NULL && lc_collate != NULL)
3630-
exit(1); /* check_winlocale printed the error */
3598+
if (wincollate == NULL && collate != NULL)
3599+
exit(1); /* check_icu_winlocale printed the error */
36313600
else
36323601
collate = (const char *) wincollate;
36333602
}
3634-
#else /* not WIN32 */
3635-
collate = (const char *) lc_collate;
3636-
#endif /* not WIN32 */
3603+
#endif /* WIN32 */
36373604

36383605
langtag = get_icu_language_tag(collate);
36393606
if (!langtag)
@@ -3644,13 +3611,13 @@ set_collation_version(void)
36443611
exit(1);
36453612
}
36463613
collate = get_icu_collate(collate, langtag);
3647-
#else
3614+
#else /* not USE_ICU */
36483615
fprintf(stderr,
36493616
_("%s: ICU is not supported in this build\n"
36503617
"You need to rebuild PostgreSQL using --with-icu.\n"),
36513618
progname);
36523619
exit(1);
3653-
#endif
3620+
#endif /* not USE_ICU */
36543621
}
36553622
else
36563623
{

src/bin/pg_upgrade/check.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ check_and_dump_old_cluster(bool live_check)
135135
if (old_cluster.edition != PG_ORIGINAL &&
136136
GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
137137
{
138-
old_9_6_pgpro_invalidate_secondary_collation_indexes(&old_cluster, true);
139-
old_9_6_pgpro_invalidate_secondary_collation_constraints(&old_cluster, true);
138+
old_9_6_pgpro_invalidate_collation_indexes(&old_cluster, true);
139+
old_9_6_pgpro_invalidate_collation_constraints(&old_cluster, true);
140140
}
141141

142142
/*
@@ -209,8 +209,8 @@ issue_warnings_and_set_wal_level(void)
209209
if (old_cluster.edition != PG_ORIGINAL &&
210210
GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
211211
{
212-
old_9_6_pgpro_invalidate_secondary_collation_indexes(&new_cluster, false);
213-
old_9_6_pgpro_invalidate_secondary_collation_constraints(&new_cluster, false);
212+
old_9_6_pgpro_invalidate_collation_indexes(&new_cluster, false);
213+
old_9_6_pgpro_invalidate_collation_constraints(&new_cluster, false);
214214
}
215215

216216
stop_postmaster(false);

src/bin/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
450450
void old_9_6_check_for_unknown_data_type_usage(ClusterInfo *cluster);
451451
void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
452452
bool check_mode);
453-
void old_9_6_pgpro_invalidate_secondary_collation_indexes(ClusterInfo *cluster,
453+
void old_9_6_pgpro_invalidate_collation_indexes(ClusterInfo *cluster,
454454
bool check_mode);
455-
void old_9_6_pgpro_invalidate_secondary_collation_constraints(ClusterInfo *cluster, bool check_mode);
455+
void old_9_6_pgpro_invalidate_collation_constraints(ClusterInfo *cluster, bool check_mode);
456456

457457
/* parallel.c */
458458
void parallel_exec_prog(const char *log_file, const char *opt_log_file,

0 commit comments

Comments
 (0)