4 CREATE CONVERSION — define a new encoding conversion
8 CREATE [ DEFAULT ] CONVERSION name
9 FOR source_encoding TO dest_encoding FROM function_name
13 CREATE CONVERSION defines a new conversion between two character set
16 Conversions that are marked DEFAULT can be used for automatic encoding
17 conversion between client and server. To support that usage, two
18 conversions, from encoding A to B and from encoding B to A, must be
21 To be able to create a conversion, you must have EXECUTE privilege on
22 the function and CREATE privilege on the destination schema.
27 The DEFAULT clause indicates that this conversion is the default
28 for this particular source to destination encoding. There should
29 be only one default encoding in a schema for the encoding pair.
32 The name of the conversion. The conversion name can be
33 schema-qualified. If it is not, the conversion is defined in the
34 current schema. The conversion name must be unique within a
38 The source encoding name.
41 The destination encoding name.
44 The function used to perform the conversion. The function name
45 can be schema-qualified. If it is not, the function will be
46 looked up in the path.
48 The function must have the following signature:
51 integer, -- source encoding ID
52 integer, -- destination encoding ID
53 cstring, -- source string (null terminated C string)
54 internal, -- destination (fill with a null terminated C string)
55 integer, -- source string length
56 boolean -- if true, don't throw an error if conversion fails
59 The return value is the number of source bytes that were
60 successfully converted. If the last argument is false, the
61 function must throw an error on invalid input, and the return
62 value is always equal to the source string length.
66 Neither the source nor the destination encoding can be SQL_ASCII, as
67 the server's behavior for cases involving the SQL_ASCII “encoding” is
70 Use DROP CONVERSION to remove user-defined conversions.
72 The privileges required to create a conversion might be changed in a
77 To create a conversion from encoding UTF8 to LATIN1 using myfunc:
78 CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
82 CREATE CONVERSION is a PostgreSQL extension. There is no CREATE
83 CONVERSION statement in the SQL standard, but a CREATE TRANSLATION
84 statement that is very similar in purpose and syntax.
88 ALTER CONVERSION, CREATE FUNCTION, DROP CONVERSION