1CREATE CONVERSION(7)     PostgreSQL 14.3 Documentation    CREATE CONVERSION(7)
2
3
4

NAME

6       CREATE_CONVERSION - define a new encoding conversion
7

SYNOPSIS

9       CREATE [ DEFAULT ] CONVERSION name
10           FOR source_encoding TO dest_encoding FROM function_name
11

DESCRIPTION

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

PARAMETERS

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                   boolean   -- if true, don't throw an error if conversion fails
55               ) RETURNS integer;
56
57           The return value is the number of source bytes that were
58           successfully converted. If the last argument is false, the function
59           must throw an error on invalid input, and the return value is
60           always equal to the source string length.
61

NOTES

63       Neither the source nor the destination encoding can be SQL_ASCII, as
64       the server's behavior for cases involving the SQL_ASCII “encoding” is
65       hard-wired.
66
67       Use DROP CONVERSION to remove user-defined conversions.
68
69       The privileges required to create a conversion might be changed in a
70       future release.
71

EXAMPLES

73       To create a conversion from encoding UTF8 to LATIN1 using myfunc:
74
75           CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
76

COMPATIBILITY

78       CREATE CONVERSION is a PostgreSQL extension. There is no CREATE
79       CONVERSION statement in the SQL standard, but a CREATE TRANSLATION
80       statement that is very similar in purpose and syntax.
81

SEE ALSO

83       ALTER CONVERSION (ALTER_CONVERSION(7)), CREATE FUNCTION
84       (CREATE_FUNCTION(7)), DROP CONVERSION (DROP_CONVERSION(7))
85
86
87
88PostgreSQL 14.3                      2022                 CREATE CONVERSION(7)
Impressum