1CREATE CONVERSION(7) PostgreSQL 13.4 Documentation CREATE CONVERSION(7)
2
3
4
6 CREATE_CONVERSION - define a new encoding conversion
7
9 CREATE [ DEFAULT ] CONVERSION name
10 FOR source_encoding TO dest_encoding FROM function_name
11
13 CREATE CONVERSION defines a new conversion between two character set
14 encodings.
15
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
19 defined.
20
21 To be able to create a conversion, you must have EXECUTE privilege on
22 the function and CREATE privilege on the destination schema.
23
25 DEFAULT
26 The DEFAULT clause indicates that this conversion is the default
27 for this particular source to destination encoding. There should be
28 only one default encoding in a schema for the encoding pair.
29
30 name
31 The name of the conversion. The conversion name can be
32 schema-qualified. If it is not, the conversion is defined in the
33 current schema. The conversion name must be unique within a schema.
34
35 source_encoding
36 The source encoding name.
37
38 dest_encoding
39 The destination encoding name.
40
41 function_name
42 The function used to perform the conversion. The function name can
43 be schema-qualified. If it is not, the function will be looked up
44 in the path.
45
46 The function must have the following signature:
47
48 conv_proc(
49 integer, -- source encoding ID
50 integer, -- destination encoding ID
51 cstring, -- source string (null terminated C string)
52 internal, -- destination (fill with a null terminated C string)
53 integer -- source string length
54 ) RETURNS void;
55
57 Neither the source nor the destination encoding can be SQL_ASCII, as
58 the server's behavior for cases involving the SQL_ASCII “encoding” is
59 hard-wired.
60
61 Use DROP CONVERSION to remove user-defined conversions.
62
63 The privileges required to create a conversion might be changed in a
64 future release.
65
67 To create a conversion from encoding UTF8 to LATIN1 using myfunc:
68
69 CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
70
72 CREATE CONVERSION is a PostgreSQL extension. There is no CREATE
73 CONVERSION statement in the SQL standard, but a CREATE TRANSLATION
74 statement that is very similar in purpose and syntax.
75
77 ALTER CONVERSION (ALTER_CONVERSION(7)), CREATE FUNCTION
78 (CREATE_FUNCTION(7)), DROP CONVERSION (DROP_CONVERSION(7))
79
80
81
82PostgreSQL 13.4 2021 CREATE CONVERSION(7)