aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/conversioncmds.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
index 419d883bd7c..8756ead5393 100644
--- a/src/backend/commands/conversioncmds.c
+++ b/src/backend/commands/conversioncmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.29 2006/07/14 14:52:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.29.2.1 2009/02/27 16:35:36 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,6 +47,7 @@ CreateConversionCommand(CreateConversionStmt *stmt)
const char *to_encoding_name = stmt->to_encoding_name;
List *func_name = stmt->func_name;
static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, INTERNALOID, INT4OID};
+ char result[1];
/* Convert list of names to a name and namespace */
namespaceId = QualifiedNameGetCreationNamespace(stmt->conversion_name,
@@ -87,6 +88,19 @@ CreateConversionCommand(CreateConversionStmt *stmt)
NameListToString(func_name));
/*
+ * Check that the conversion function is suitable for the requested
+ * source and target encodings. We do that by calling the function with
+ * an empty string; the conversion function should throw an error if it
+ * can't perform the requested conversion.
+ */
+ OidFunctionCall5(funcoid,
+ Int32GetDatum(from_encoding),
+ Int32GetDatum(to_encoding),
+ CStringGetDatum(""),
+ CStringGetDatum(result),
+ Int32GetDatum(0));
+
+ /*
* All seem ok, go ahead (possible failure would be a duplicate conversion
* name)
*/