*** pgsql/src/backend/commands/conversioncmds.c 2008/01/01 19:45:48 1.32 --- pgsql/src/backend/commands/conversioncmds.c 2009/02/27 16:35:31 1.32.2.1 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.31 2007/02/14 01:58:56 tgl Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.32 2008/01/01 19:45:48 momjian Exp $ * *------------------------------------------------------------------------- */ *************** CreateConversionCommand(CreateConversion *** 47,52 **** --- 47,53 ---- 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, *************** CreateConversionCommand(CreateConversion *** 87,92 **** --- 88,106 ---- 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) */