Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit390cf32

Browse files
committed
Refrain from canonicalizing a client_encoding setting of "UNICODE".
While "UTF8" is the correct name for this encoding, existing JDBC driversexpect that if they send "UNICODE" it will read back the same way; theyfail with an opaque "Protocol error" complaint if not. This will be fixedin the 9.1 drivers, but until older drivers are no longer in use in thewild, we'd better leave "UNICODE" alone. Continue to canonicalize allother inputs. Per report from Steve Singer and subsequent discussion.
1 parentca5a75f commit390cf32

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

‎src/backend/commands/variable.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,16 @@ bool
759759
check_client_encoding(char**newval,void**extra,GucSourcesource)
760760
{
761761
intencoding;
762+
constchar*canonical_name;
762763

763764
/* Look up the encoding by name */
764765
encoding=pg_valid_client_encoding(*newval);
765766
if (encoding<0)
766767
return false;
767768

769+
/* Get the canonical name (no aliases, uniform case) */
770+
canonical_name=pg_encoding_to_char(encoding);
771+
768772
/*
769773
* If we are not within a transaction then PrepareClientEncoding will not
770774
* be able to look up the necessary conversion procs. If we are still
@@ -786,7 +790,7 @@ check_client_encoding(char **newval, void **extra, GucSource source)
786790
/* Must be a genuine no-such-conversion problem */
787791
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
788792
GUC_check_errdetail("Conversion between %s and %s is not supported.",
789-
pg_encoding_to_char(encoding),
793+
canonical_name,
790794
GetDatabaseEncodingName());
791795
}
792796
else
@@ -798,13 +802,27 @@ check_client_encoding(char **newval, void **extra, GucSource source)
798802
}
799803

800804
/*
801-
* Return the encoding's canonical name, and save its ID in *extra.
805+
* Replace the user-supplied string with the encoding's canonical name.
806+
* This gets rid of aliases and case-folding variations.
807+
*
808+
* XXX Although canonicalizing seems like a good idea in the abstract, it
809+
* breaks pre-9.1 JDBC drivers, which expect that if they send "UNICODE"
810+
* as the client_encoding setting then it will read back the same way.
811+
* As a workaround, don't replace the string if it's "UNICODE". Remove
812+
* that hack when pre-9.1 JDBC drivers are no longer in use.
802813
*/
803-
free(*newval);
804-
*newval=strdup(pg_encoding_to_char(encoding));
805-
if (!*newval)
806-
return false;
814+
if (strcmp(*newval,canonical_name)!=0&&
815+
strcmp(*newval,"UNICODE")!=0)
816+
{
817+
free(*newval);
818+
*newval=strdup(canonical_name);
819+
if (!*newval)
820+
return false;
821+
}
807822

823+
/*
824+
* Save the encoding's ID in *extra, for use by assign_client_encoding.
825+
*/
808826
*extra=malloc(sizeof(int));
809827
if (!*extra)
810828
return false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp