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

Commit5c4ca3b

Browse files
committed
In CREATE CONVERSION, test that the given function is a valid conversion
function for the specified source and destination encodings. We do that bycalling the function with an empty string. If it can't perform the requestedconversion, it will throw an error.Backport to 7.4 - 8.3. Per bug report #4680 by Denis Afonin.
1 parent92fc8b4 commit5c4ca3b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎src/backend/commands/conversioncmds.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.37 2009/01/01 17:23:37 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.38 2009/02/27 16:35:26 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -49,6 +49,7 @@ CreateConversionCommand(CreateConversionStmt *stmt)
4949
constchar*to_encoding_name=stmt->to_encoding_name;
5050
List*func_name=stmt->func_name;
5151
staticOidfuncargs[]= {INT4OID,INT4OID,CSTRINGOID,INTERNALOID,INT4OID};
52+
charresult[1];
5253

5354
/* Convert list of names to a name and namespace */
5455
namespaceId=QualifiedNameGetCreationNamespace(stmt->conversion_name,
@@ -95,6 +96,19 @@ CreateConversionCommand(CreateConversionStmt *stmt)
9596
aclcheck_error(aclresult,ACL_KIND_PROC,
9697
NameListToString(func_name));
9798

99+
/*
100+
* Check that the conversion function is suitable for the requested
101+
* source and target encodings. We do that by calling the function with
102+
* an empty string; the conversion function should throw an error if it
103+
* can't perform the requested conversion.
104+
*/
105+
OidFunctionCall5(funcoid,
106+
Int32GetDatum(from_encoding),
107+
Int32GetDatum(to_encoding),
108+
CStringGetDatum(""),
109+
CStringGetDatum(result),
110+
Int32GetDatum(0));
111+
98112
/*
99113
* All seem ok, go ahead (possible failure would be a duplicate conversion
100114
* name)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp